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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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