BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I ask prefix "value" but in result I see prefix "value1"- what is the reason?

I want to get new column name "value" and not "value1"


data wide; 
  input famid faminc96 faminc97 faminc98 ; 
cards; 
1 40000 40500 41000 
2 45000 45400 45800 
3 75000 76000 77000 
; 
run; 
proc transpose data=wide out=long prefix=value;
   by famid;
run;
3 REPLIES 3
PaigeMiller
Diamond | Level 26
proc transpose data=wide out=long(rename=(value1=value)) prefix=value;
--
Paige Miller
ballardw
Super User

The reason is that is the way Proc Transpose works. It does not know that you will only have one value as each duplicate of the BY variable(s) increments the count.

 

Essential Meaning of prefix

: to add a letter, number, or symbol at the beginning of a word or number
So the Prefix option just says what the output variable names start with.
data_null__
Jade | Level 19

You could use the ID statement which would build-in a check for unique BY groups.

 

data wide; 
  input famid faminc96 faminc97 faminc98 ; 
  retain id 'Value';
cards; 
1 40000 40500 41000 
2 45000 45400 45800 
3 75000 76000 77000 
; 
run; 
proc transpose data=wide out=long;
   by famid;
   id id;
   run;
proc print;
   run;

Capture.PNG

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 3 replies
  • 554 views
  • 2 likes
  • 4 in conversation