Date: Wed, 13 May 2009 09:32:15 -0400
Reply-To: msz03@albany.edu
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Summarize Combinations of Activities?
Content-Type: text/plain;charset=iso-8859-1
hi ... you could try ... (add a SORT by ACT_ID if the data are not in that order prior to the new data step)
data old;
input act_id $ sequence color : $6.;
datalines;
10JN-123 1 red
10JN-123 2 yellow
10JN-123 3 orange
10JN-234 1 red
10JN-234 2 yellow
10JN-234 3 orange
10JN-345 1 yellow
10JN-345 2 red
10JN-456 1 yellow
10JN-456 2 orange
10JN-456 3 red
10JN-567 1 blue
10JN-567 2 red
10JN-678 1 blue
10JN-678 2 red
10JN-678 3 orange
10JN-789 1 blue
10JN-789 2 red
10JN-789 3 yellow
10JN-890 1 blue
10JN-901 1 yellow
10JN-902 1 yellow
10JN-902 2 orange
10JN-902 3 red
;
run;
data new;
length new_var $50;
do until(last.act_id);
set old;
by act_id;
new_var = catx(' ',new_var,color);
end;
do until(last.act_id);
set old;
by act_id;
output;
end;
run;
proc print data=new;
run;
--
Mike Zdeb
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
> easy:
> proc freq data = Libref.MyData
> tables Act_Id * Color
> / list missing noprint
> out = Work.List_Colors;
>
> Proc Transpose data = Work.List_Colors;
>
> see also:
>
> http://www.sascommunity.org/wiki/Processing_Check-All-That-Apply
>
> Ron Fehd the module/routine/subroutine maven CDC Atlanta GA USA RJF2
> at cdc dot gov
>
>
>
>> -----Original Message-----
>> From: owner-sas-l@listserv.uga.edu
>> [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of
>> marzlet.sas@gmail.com
>> Sent: Tuesday, May 12, 2009 5:42 PM
>> To: sas-l@uga.edu
>> Subject: Summarize Combinations of Activities?
>>
>> I've simplified the data in this snapshot to show that the act_id
>> separates a new activity, from the next. Activity 10JN-123 contains 3
>> colors, and currently only the 3 variables are act_id, sequence, and
>> color.
>>
>> I'm trying to determine a few things:
>> - I would like to create the 'new-var' so that i can list out the
>> frequency of al the various combinations the color combinations.
>> - Ultimately I want to determine the percentage of how often is there
>> a second color? (80%)
>> What percentage of the time is there a third color? (60%)
>>
>> act_id sequence color new_var
>> 10JN-123 1 red red yellow orange
>> 10JN-123 2 yellow red yellow orange
>> 10JN-123 3 orange red yellow orange
>> 10JN-234 1 red red yellow orange
>> 10JN-234 2 yellow red yellow orange
>> 10JN-234 3 orange red yellow orange
>> 10JN-345 1 yellow yellow red
>> 10JN-345 2 red yellow red
>> 10JN-456 1 yellow yellow orange red
>> 10JN-456 2 orange yellow orange red
>> 10JN-456 3 red yellow orange red
>> 10JN-567 1 blue blue red
>> 10JN-567 2 red blue red
>> 10JN-678 1 blue blue red orange
>> 10JN-678 2 red blue red orange
>> 10JN-678 3 orange blue red orange
>> 10JN-789 1 blue blue red yellow
>> 10JN-789 2 red blue red yellow
>> 10JN-789 3 yellow blue red yellow
>> 10JN-890 1 blue blue
>> 10JN-901 1 yellow yellow
>> 10JN-902 1 yellow yellow orange red
>> 10JN-902 2 orange yellow orange red
>> 10JN-902 3 red yellow orange red
>>
>> Any insight would be greatly appreciated - thanks in advance!
>> Megan
>>
>>
>