Hello
I have a data set called aaa and by using proc transpose I want to get another data set called bbb.
The result of bbb data set is not as I want because under column "pet" I expect to have only 3 rows: dog,cat,fish
Data aaa;
input pet_owner $ pet $ poulation;
cards;
Dave dog 2
Dave cat 1
Yulia dog 2
Yulia cat 2
Joe fish 7
Joe dog 1
Joe cat 1
;
run;
proc transpose data=aaa name=Metric out=bbb;
id pet_owner;
by pet NOTSORTED;
var poulation;
run;
The result you get is 100% correct when using "notsorted", the docs say: "If observations with the same values for the BY variables are not contiguous, then the procedure treats each contiguous set as a separate BY group."
You will have to sort dataset aaa to get what you want.
The result you get is 100% correct when using "notsorted", the docs say: "If observations with the same values for the BY variables are not contiguous, then the procedure treats each contiguous set as a separate BY group."
You will have to sort dataset aaa to get what you want.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.