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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1148 views
  • 0 likes
  • 3 in conversation