Hi all,
Looking to manage my data.
HAVE:
want:
Please explain:
Other than those issues, this is really just a PROC TRANSPOSE with BY statement — although depending on what analysis you will do next, you might want to leave the data un-transposed. So what analysis are you going to do next?
UNTESTED CODE
proc transpose data=have out=want;
by trt subject;
var grade;
id test;
run;
Then you can turn the zeros into spaces or dashes as desired.
If you want tested code, and for all questions you might ask in the future, we cannot use data in a screen capture. Provide data as SAS data step code, which you can type yourself, or you can follow these instructions. Consider this mandatory in the future, data only as SAS data step code, not screen captures, not Excel files.
Please explain:
Other than those issues, this is really just a PROC TRANSPOSE with BY statement — although depending on what analysis you will do next, you might want to leave the data un-transposed. So what analysis are you going to do next?
UNTESTED CODE
proc transpose data=have out=want;
by trt subject;
var grade;
id test;
run;
Then you can turn the zeros into spaces or dashes as desired.
If you want tested code, and for all questions you might ask in the future, we cannot use data in a screen capture. Provide data as SAS data step code, which you can type yourself, or you can follow these instructions. Consider this mandatory in the future, data only as SAS data step code, not screen captures, not Excel files.
Thank you @PaigeMiller for the input.
I would only like to populate values who have grades. For the trt 1, there are no grades.
I have used the above code and It is giving me like below:
Please provide the data as SAS data step code, as I requested.
Also, please show the exact code you used.
data have;
input trt subject test 3$ grade;
cards;
1 1 ALT 0
1 1 AST 0
1 1 BILI 0
1 1 GGT 0
1 3 ALT 0
1 3 AST 0
1 3 BILI 1
1 3 GGT 2
2 4 ALT 1
2 4 AST 0
2 4 BILI 0
2 4 GGT 0
2 5 ALT 0
2 5 AST 2
2 5 BILI 0
2 5 GGT 3
3 6 ALT 0
3 6 AST 0
3 6 BILI 0
3 6 GGT 1
3 10 ALT 0
3 10 AST 4
3 10 BILI 1
3 10 GGT 0
;
run;
proc transpose data = have out=want prefix=_;
by trt subject test descending grade;
var grade;
id test;
run;
@RAVI2000 wrote:
proc transpose data = have out=want prefix=_; by trt subject test descending grade;
var grade;
id test;
run;
That's not the code I provided. In fact the code I provided seems to work perfectly on your data.
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.