BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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?

1 ACCEPTED SOLUTION

Accepted Solutions
JeanDo
Obsidian | Level 7

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,

View solution in original post

2 REPLIES 2
JeanDo
Obsidian | Level 7

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,

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 918 views
  • 1 like
  • 3 in conversation