BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

A common trick it to introduce a new new group in the data that has all of the values.  This is also frequently done to insure that the names are created in the order wanted.  You can even do this using a data step view so that you don't need to make a second copy of your original data.  You can then remove the extra group from the output dataset.  You should also use the PREFIX= option to tell PROC TRANSPOSE how to name the new variables since names like 1,2,3 etc are not really valid or useful.

data test_fixed / view=test_fixed;
  if 0 then set test;
  if _n_=1 then do month=1 to 49; output; end;
  set test;
run;

proc transpose data=test_fixed prefix=MONTH
  out=test_t(where=(not missing(id)))
;
  by ID;
  id month;
  var sale;
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 15 replies
  • 2503 views
  • 2 likes
  • 6 in conversation