Hi all,
i have a data set with 100 obs like below.
ORGAN |
CELLTYPE |
COUNT_PERCENT |
Liver |
Livercell1 |
12(12.22%) |
Liver |
Livercell2 |
23(23.22%) |
Liver |
Livercell3 |
32(23.11%)) |
|
|
|
Kidney |
Nkcell1 |
45(23.21%) |
Kidney |
Nkcell2 |
34(48.34%) |
Kidney |
Nkcell3 |
34(48.22%) |
|
|
|
Heart |
Myocardialcell1 |
34.22(11%) |
Heart |
Myocardialcell2 |
22.22(56.22%) |
Heart |
Myocardialcell3 |
23.22(12.33%) |
|
|
|
I want to produce an output something like
Category |
COUNT_PERCENT |
Liver |
|
Livercell1 |
12(12.22%) |
Livercell2 |
23(23.22%) |
Livercell3 |
32(23.11%)) |
Kidney |
|
Nkcell1 |
45(23.21%) |
Nkcell2 |
34(48.34%) |
Nkcell3 |
34(48.22%) |
Heart |
|
Myocardialcell1 |
34.22(11%) |
Myocardialcell2 |
22.22(56.22%) |
Myocardialcell3 |
23.22(12.33%) |
|
|
kindly suggest some ideas? i have found a way by giving orders to the extracted unique values of organ column and by using a set command placed one dataset above another and did a sorting. but the process is lengthy. is there a way in macro to go ahead in solving this problem?
Hi,
You can also try the following SAS code:
proc sort data=your-table-name out=input_tab presorted;
by organ;
run;
data output_tab (keep=category count_percent);
set input_tab (rename=(count_percent=count_temp));
by organ;
if first.organ then do;
category=organ;
count_percent='';
output;
end;
category=celltype;
count_percent=count_temp;
output;
run;
Help that it'll work.
Regards,
Hi,
You can also try the following SAS code:
proc sort data=your-table-name out=input_tab presorted;
by organ;
run;
data output_tab (keep=category count_percent);
set input_tab (rename=(count_percent=count_temp));
by organ;
if first.organ then do;
category=organ;
count_percent='';
output;
end;
category=celltype;
count_percent=count_temp;
output;
run;
Help that it'll work.
Regards,
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.