11-05-2012 07:45 PM
Suppose I have a data set with three groups Abc,Def,Ghi Something like this:
The x variable doesn't really matter. I want to be able to write to the LOG "Name of Group1: Abc (n=3)" "Name of Group2: Def (n=4)" "Name of Group3: Ghi (n=2)".
Is there a way that I can automatically extract the different group names and their sample size (perhaps with a function)?? I should add that this will be part of a larger macro so it needs to be "macro-friendly".
11-05-2012 09:05 PM
Not sure if this is you are after, also not sure what is "macro-friendly", all I know there is hardly any SAS code can NOT be wrapped up using macro.
input Group$ X_var;
do i=1 by 1 until (last.group);
by group notsorted;
put "Name of Group" _n_ ":" group "(n=" i ")";