Hello
I am using proc transpose to change from long to wide.
The second proc transpose is not working well and I see only zeros...
data have;
infile datalines truncover;
format PCT percent8.2;
input mon prevmon category category_PrevMon nr PCT percent8.2 ;
cards;
202503 202502 1 1 100 10%
202503 202502 1 2 200 20%
202503 202502 1 3 50 5%
202503 202502 2 1 50 4%
202503 202502 2 2 10 1%
202503 202502 2 3 300 30%
202503 202502 3 1 150 15%
202503 202502 3 2 70 7%
202503 202502 3 3 80 8%
;
Run;
proc sort data=have;by mon;Run;
proc tabulate data=have format=8.2 ;
BY mon ;
class category_PrevMon category ;
var nr;
table category_PrevMon='' all, (category='' all)*(SUM=''*nr=''*f=8.) / rts=10 misstext='0' box='';
run;
proc tabulate data=have format=8.2 ;
BY mon ;
class category_PrevMon category ;
var PCT;
table category_PrevMon='' all, (category='' all)*(SUM=''*PCT=''*f=8.) / rts=10 misstext='0' box='';
run;
Due to your PCT variable is too small, you need to add PERCENTw.d or other format as @Kurt_Bremser pointed out.
proc tabulate data=have format=8.2 ; BY mon ; class category_PrevMon category ; var PCT; table category_PrevMon='' all, (category='' all)*(SUM=''*PCT=''*f=percent8.2) / rts=10 misstext='0' box=''; run;
Due to your PCT variable is too small, you need to add PERCENTw.d or other format as @Kurt_Bremser pointed out.
proc tabulate data=have format=8.2 ; BY mon ; class category_PrevMon category ; var PCT; table category_PrevMon='' all, (category='' all)*(SUM=''*PCT=''*f=percent8.2) / rts=10 misstext='0' box=''; run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.