Hi, All
I want to create a cross table to summaries favorite before and after test the tasty and put stage 1 and stage 2 together. I have created codes to create the result, but could not report it as follow in rtf file, I am wondering if anyone can help?
rtf ouput I want as follow:
The code as following:
data raw;
input (Subject Stage Before After) ($);
cards;
1 I Like Like
2 II Abit Like
3 I Like Abit
4 II Abit Like
5 I Like Abit
6 II Like Like
7 II Abit Like
8 I Like Dislike
9 II Like Abit
10 I Dislike Like
11 II Abit Dislike
12 I Like ND
;
run;
proc sort data=raw;
by Stage;
run;
data class;
format Before $8. After $8.;
do Before='Like', 'Abit', 'Dislike', 'ND';
do After='Like', 'Abit', 'Dislike', 'ND';
output;
end;
end;
run;
proc format;
value $FBefore
'Like'='Like'
'Abit'='A bit like'
'Dislike'='Dislike'
'ND'='Not Done';
value $FAfter
'Like'='Like'
'Abit'='A bit like'
'Dislike'='Dislike'
'ND'='Not Done';
run;
proc tabulate data=raw missing classdata=class;
format Before $FBefore. After $FAfter.;
class Before After/order=data;
table After, Before*(N=' ')/misstext='0';
by Stage;
run;
I think that instead of BY stage that you want Stage as a class variable in the column expression area. That would require modifying your classdata set to include stage.
Or use the PRELOADFMT option instead of class data.
proc tabulate data=raw missing ; format Before $FBefore. After $FAfter.; class Before After/order=data preloadfmt; format before $fbefore.; class stage; table After, stage* Before*(N=' ')/misstext='0' printmiss; ; run;
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.