I have a dataset that has data as follows:
Name Zip Measure_ID Score
Hospital A 12345 Rate1 0.2
Hospital A 12345 Rate2 .
Hospital A 12345 Rate3 .
Hospital B 54321 Rate1 1.5
Hospital B 54321 Rate2 0.4
Hospital B 54321 Rate3 .
Hospital C 24680 Rate1 .
Hospital C 24680 Rate2 .
Hospital C 24680 Rate3 .
I would like to have it by hospital:
Name Zip Rate1 Rate2 Rate3
Hospital A 12345 0.2 . .
Hospital B 54321 1.5 0.4 .
Hospital C 24680 . . .
I sorted the dataset by hospital and started by converting measure_id to columns through an array:
array measure (3) rate1 rate2 rate3;
But, I can't figure out how to handle the score column since I don't want to give it its own columns, I essentially want to make it the values while measure_id becomes column names.
May be easier than you think:
proc transpose data=have out=want (drop=_name_)
;
by name;
copy zip;
id measure_id;
run;
Drop=_name_ excludes the column that would have the original variable Score.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.