BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

Ksharp_1-1744881156106.png

 

View solution in original post

2 REPLIES 2
Ksharp
Super User

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;

Ksharp_1-1744881156106.png

 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 365 views
  • 4 likes
  • 3 in conversation