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

I have been given a dataset to analyze and some of the variable names are longer than 32 characters and thus I get error messages when I am trying to analyze these variables. How do I change the variable name to be less than 32 characters?

I have tried this:

data hemo.play;

set hemo.hemo_mrg2 (RENAME=(WhiteAfricanAmericanAmericanIndianPacificIslanderOther=Race));

Run;

I still get the same error message that the variable exceeds the 32 character limit.

Thank you for the help.

1 ACCEPTED SOLUTION

Accepted Solutions
Peter_C
Rhodochrosite | Level 12

@uwmsasuser

please run the following code replacing "your.data" with the name of your data.

PROC CONTENTS VARNUM DATA= your.data ;

RUN;

That should create a report indicating your column names.

View solution in original post

7 REPLIES 7
art297
Opal | Level 21

What kind of dbms is the library hemo?  If it is pointing to a library of SAS datasets, the name can't be more than 32 characters long to begin with.

uwmsasuser
Calcite | Level 5

It is a SAS library. The data was imported from Excel and the variables were imported just as they were in excel so I have variable names in my SAS dataset that are more than 32 characters. I can view the data within those variables when I look at the data table but cannot manipulate the variable in anyway since the name is too long.

PGStats
Opal | Level 21

When I import an Excel column named "WhiteAfricanAmericanAmericanIndianPacificIslanderOther" into SAS, it gets the SAS variable name "WhiteAfricanAmericanAmericanIndi" and label "WhiteAfricanAmericanAmericanIndianPacificIslanderOther"

PG

PG
ballardw
Super User

Perhaps the LABEL is that long? When viewing the table click on the column header to display variable properties and see if you have a shorter variable NAME that possibly has spaces replaced with _, and a Label the full length of the original column heading.

Peter_C
Rhodochrosite | Level 12

@uwmsasuser

please run the following code replacing "your.data" with the name of your data.

PROC CONTENTS VARNUM DATA= your.data ;

RUN;

That should create a report indicating your column names.

rasmuslarsen
Obsidian | Level 7

 

 

I can't see how this answers the question?

 

The OPs problem is that a variable name is too long.

Running a proc contents will list the variables, but not change the fact a variable name is too long. After running proc contents it is still not possible to rename the variable.

 

What am I missing here?

 

 

uwmsasuser
Calcite | Level 5

Thank you for the help. My column name was showing the full name which was the LABEL and not the variable name. You are correct that SAS was truncating the variable. Thank you all!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 7 replies
  • 15983 views
  • 3 likes
  • 6 in conversation