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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.