BookmarkSubscribeRSS Feed
jdk123
Calcite | Level 5
dataset contains the followwing values:
tem1
year acct1 acct2 acct3

2001 $100.0 200 $300
2002 $400 500 $600


after transpose:

proc transpose data=tem1 out=tem ;
id year;

run;

2001 2002
acct1 100 400
acct2 200 500
acct3 300 600

what I am expecting after the transpose:


2001 2002
acct1 $100 $400
acct2 200 500
acct3 $300 $600

question:

how can i keep the original format of the data? such as the $100..
3 REPLIES 3
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Jdk 123,

It is impossible to have different formats for different observations for the same variable. So it is only possible to emulate this:
[pre]
data tem1;
input year acct1 $ acct2 $ acct3 $;
datalines;
2001 $100.0 200 $300
2002 $400 500 $600
run;
proc transpose data=tem1 out=tem ;
id year;
var acct1 acct2 acct3;
run;
[/pre]
Sincerely,
SPR
jdk123
Calcite | Level 5
Thanks so lot.you have been great help.
Ksharp
Super User
I am confused .But my code work fine.
If you also have problem ,can manually to format them
format _: dollar10. ;


[pre]
data temp;
input year (acct1 acct2 acct3 ) ( : dollar10.);
format acct: dollar10.;
datalines;
2001 $100.0 200 $300
2002 $400 500 $600
run;
proc transpose data=temp out=tem ;
id year;
run;
proc print noobs;run;




_NAME_ _2001 _2002

acct1 $100 $400
acct2 $200 $500
acct3 $300 $600
[/pre]




Ksharp

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 1667 views
  • 0 likes
  • 3 in conversation