BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sasadomo
Calcite | Level 5

I was using the following lines:

 

proc transpose data =Weighted1 out =Weighted2
(rename = ( '1'n =ret_top '2'n=ret_bot) drop = _label_ );
...

where I wanted to rename variable named "1"  and named "2" in Weighted1 to "ret_tap" and "ret_bot" but SAS shows error for above line 2. How would Reference to such a variable?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

No, it's a SAS option.

 

This is what I recommend:

 

options validvarname=V7;

It means SAS will default to valid SAS names, by replacing spaces with _ and adding _ before variables with a 1 or 2. 

 


@Sasadomo wrote:

Thank you for your response, do I apply VALIDVARNAME=ANY option in the proc Transposes  command?


 

View solution in original post

6 REPLIES 6
AndrewHowell
Moderator

To help us to help you, are you able to supply (sample) data & the actual log?

Sasadomo
Calcite | Level 5

Thank you for you reply

 

I want Weighted2 as this: 20180422212400.png

 And in weighted1 "1" "2" are the variable name 

 

Attached is the log

Reeza
Super User

You don't show us what you're starting with, so it's still not clear. 

 

However, when SAS Transposes variables it automatically names them (usually col1, col2 etc), and I strongly suspect the names are not 1 or 2, so you first need to find the output names. I would do so by running the PROC TRANSPOSE, seeing the output data set and then renaming the variables accordingly. You probably want to run PROC CONTENTS to get the names. In general, I prefer to turn off the VALIDVARNAME=ANY option so I don't get names like '1'n in the first place. 

 

 

 

 


@Sasadomo wrote:

 

 

I want Weighted2 as this: 20180422212400.png

Sasadomo
Calcite | Level 5

Thank you for your response, do I apply VALIDVARNAME=ANY option in the proc Transposes  command?

Reeza
Super User

No, it's a SAS option.

 

This is what I recommend:

 

options validvarname=V7;

It means SAS will default to valid SAS names, by replacing spaces with _ and adding _ before variables with a 1 or 2. 

 


@Sasadomo wrote:

Thank you for your response, do I apply VALIDVARNAME=ANY option in the proc Transposes  command?


 

Kurt_Bremser
Super User

Maxim 3: Know your data.

Run the proc transpose without the rename, inspect the variable names in weighted2, and then rewrite the rename accordingly.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 2960 views
  • 0 likes
  • 4 in conversation