BookmarkSubscribeRSS Feed
Arun_shSAS
Fluorite | Level 6

* I want to retain my format of values even after proc transpose how to do that;

 


data a;
input year groupx respondents resa resb resc;
cards;
2007 5 10 100 . .
2008 4 13 61 23 15
2009 5 13 38 53 7
2010 7 20 60 25 15
;
run;


proc transpose data=a out=b;
run;


proc transpose data=b out=c(drop=_name_);
run;


data d(drop=i resa resb resc);
set c;
format b1 b2 b3 percent6.;
array a[*] resa resb resc ;
array b[3] b1 b2 b3;
do i=1 to 3;
b{i}=a{i}/100;
end;
run;

 

 

1 REPLY 1
PGStats
Opal | Level 21

The format will be retained when the transposed variables share the same format. Look at this example:

 

data a;
input year groupx respondents resa resb resc;
format resa resb resc z4.0;
cards;
2007 5 10 100 . .
2008 4 13 61 23 15
2009 5 13 38 53 7
2010 7 20 60 25 15
;

proc transpose data=a out=b;
by year groupx respondents notsorted;
var resa resb resc;
run;


proc transpose data=b out=c(drop=_name_);
by year groupx respondents notsorted;
var col1;
id _name_;
run;

PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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