Sas multiple rename statement

The method of renaming variables has already been shown by @ed_sas_member in Message #4 in this thread.

As stated above, if you are getting character variables as a result, then something else is wrong, most likely the variables are already character variables. Please show us a PROC CONTENTS output of this data set.

If somehow PROC CONTENTS shows these variables as numeric then we need to see the EXACT code you are using to rename, and a PROC CONTENTS on the output data set.

--
Paige Miller 11 REPLIES 11 Meteorite | Level 14 Re: renaming multiple variables Posted 12-31-2019 12:35 PM (44338 views) | In reply to TANMOY05

Pleas provide some sample data Thank you

Obsidian | Level 7 Re: renaming multiple variables Posted 12-31-2019 12:53 PM (44326 views) | In reply to ed_sas_member

like in the following dataset I want to replace variables cohort_11, cohort_12 and cohort_13 with numeric variable names c11,c12 and c13 respectively. how to do it?

Meteorite | Level 14 Re: renaming multiple variables Posted 12-31-2019 01:00 PM (44321 views) | In reply to TANMOY05
data want; set have; rename cohort_11 = c11 cohort_12 = c12 cohort_13 = c13; run;
Obsidian | Level 7 Re: renaming multiple variables Posted 12-31-2019 01:03 PM (44317 views) | In reply to ed_sas_member

yeah but by this method, I am getting character variables, but I want SAS to read the new variables as numeric variables, so how to do this?

Super User Re: renaming multiple variables Posted 12-31-2019 01:11 PM (44307 views) | In reply to TANMOY05
@TANMOY05 wrote:

yeah but by this method, I am getting character variables, but I want SAS to read the new variables as numeric variables, so how to do this?

If the "renamed" variables are character then your original variables are character. You would have to use an input statement for each variable.

The picture of the data you show makes be strongly suspect that it is the result of Proc Transpose. If that is the case then likely the best approach would be to create a SINGLE numeric variable from what ever value was transposed with something like:

set have; /* the set BEFORE transpose*/

Then transpose the data with the NUMVAL instead of your character value.