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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 349 views
  • 2 likes
  • 4 in conversation