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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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