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,
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.