Date: Wed, 2 Jul 2008 18:38:20 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: how to creat this indicator?
Mike,
If I correctly understand what you are trying to do, then I don't think it
involves using any loops (although that is definitely a useful concept to
learn).
Does the following accomplish what you are trying to do?
data have;
input industry $ year ind $24. case;
cards;
Banking 1994 Ultimate Filed 1
Banking 1995 7
Banking 1996 0
Banking 1997 56
Banking 1994 Settled Cases 0
Banking 1995 1
Banking 1996 1
Banking 1997 1
Mining 1994 Ultimate Filed 2
Mining 1995 Excluding Institutional 3
Mining 1996 4
Mining 1997 0
;
data want (drop=last:);
length industry $32;
format last_industry $32.;
set have;
retain last_ind last_industry;
if index(last_industry,"Excluding Institutional") gt 0 then do;
industry=last_industry;
ind=last_ind;
end;
else if ind eq "Excluding Institutional" then do;
industry=catt(industry,ind);
ind=last_ind;
last_industry=industry;
end;
else if not(missing(ind)) then do;
last_ind=ind;
call missing (last_industry);
end;
else ind=last_ind;
run;
HTH,
Art
-----------
On Wed, 2 Jul 2008 21:33:50 +0000, Bi Xiaoke <bixiaoke@HOTMAIL.COM> wrote:
>hello all,
>
>i have a dataset looks like below:
>
>industry year ind case Banking 1994
Ultimate Filed 1 Banking
1995 7 Banking
1996 0 Banking
1997 56 Banking 1994 Settled
Cases 0 Banking 1995 1
Banking 1996 1 Banking
1997 1 Mining 1994 Ultimate
Filed 2 Mining 1995 Excluding Institutional 3
Mining 1996 4 Mining
1997 0
>
>i'd like to change it to below:
>
>industry year ind case
Institution_indBanking 1994 Ultimate Filed 1 Banking 1995
Ultimate Filed 7 Banking 1996 Ultimate Filed 0 Banking 1997
Ultimate Filed 56 Banking 1994 Settled Cases 0 Banking 1995
Settled Cases 1 Banking 1996 Settled Cases 1 Banking 1997
Settled Cases 1 Mining 1994 Ultimate Filed 2
Excluding InstitutionalMining 1995 Ultimate Filed
3 Excluding InstitutionalMining 1996 Ultimate
Filed 4 Excluding InstitutionalMining 1997
Ultimate Filed 0 Excluding Institutional
>
>
>"ind" is the status indicator but it messes with institutional indicator.
the "Excluding ..." is always next to the "Ultimate Filed" or "Settled .."
>"year" is a variable that may increase within the industry, e.g. for
mining, year may from 1994 to 2008.
>
>i am not familar with loop within the variable. i appreciate it if
someone could give me some advise of how to create such dateset.
>
>thanks!
>
>Mike
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>_________________________________________________________________
>Making the world a better place one message at a time.
>http://www.imtalkathon.com/?source=EML_WLH_Talkathon_BetterPlace