BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Satish_Parida
Lapis Lazuli | Level 10
data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;

proc sort data=have;
by byvar;
run; 
                                                                                   
proc transpose data=have 
				out=want(keep=byvar _name_ Value1 rename=(_name_=var_name Value1=Value))
				prefix=Value;
  by byvar;                                                                          
  var a b c;                                                      
run;

Can we have the datatype of column "Value" in "want" table set to character datatype during transpose?

If we have a mixed datatype in the input "have" table it is working fine.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I don't think so. Perhaps simply do it in a data step?

 

data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;

data want(keep=byvar name Value);
   set have;
   array _{3} a b c;
   do i=1 to dim(_);
      name=vname(_[i]);
      Value=put(_[i], 8. -l);
      output;
   end;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

I don't think so. Perhaps simply do it in a data step?

 

data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;

data want(keep=byvar name Value);
   set have;
   array _{3} a b c;
   do i=1 to dim(_);
      name=vname(_[i]);
      Value=put(_[i], 8. -l);
      output;
   end;
run;
PeterClemmensen
Tourmaline | Level 20

@Satish_Parida did you try my code and did it work for you? 🙂

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 938 views
  • 1 like
  • 2 in conversation