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;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 3151 views
  • 2 likes
  • 6 in conversation