Hello All,
I want below as my output ,Meaning I want catx of all observation.
fName | Name | Sex | Age | Height | Weight | Total |
Alice | F | 13 | 56.5 | 84 | Alice | |
Alice | Barbara | F | 13 | 65.3 | 98 | Barbara,Alice |
Barbara | Carol | F | 14 | 62.8 | 102.5 | Carol,Barbara,Alice |
Carol | Jane | F | 12 | 59.8 | 84.5 | Jane,Carol,Barbara,Alice |
Jane | Janet | F | 15 | 62.5 | 112.5 | Janet,Jane,Carol,Barbara,Alice |
Janet | Joyce | F | 11 | 51.3 | 50.5 | Joyce,Janet,Jane,Carol,Barbara,Alice |
Joyce | Judy | F | 14 | 64.3 | 90 | JudyJoyce,Janet,Jane,Carol,Barbara,Alice |
I have written below code
data new;
retain fName a;
set sashelp.class;
fname=lag(Name);
Total=catx(',',Name,fname);
run;
Could any one suggest best possible wqay to get desire output also it would be helpful if get only unique values in 'Total' Variable.
Thanks
Hello,
Does the following program answer your problem ?
data new;
set sashelp.class;
length Total $1000.;
retain total;
if _N_=1 then Total=Name;
else Total=catx(',',Name,Total);
run;
Hello,
Does the following program answer your problem ?
data new;
set sashelp.class;
length Total $1000.;
retain total;
if _N_=1 then Total=Name;
else Total=catx(',',Name,Total);
run;
Yes ,I found the way.
Thanks a lot for response
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.