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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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