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

I have a survey imported into SAS where the variables are the questions themselves (for example: "What is your age?")

 

I am just trying to get a idea of the contents of the dataset with functions like proc print but I'm not sure of the syntax.

 

How would I go writing those variables as in below?

 

proc print data=mydata;

var What is your age?; run;

 

I have tried with single and double quotation marks but no success yet.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

SAS variable names are limited to 32 characters so ideally try to import your data with more suitable variable names that conform to SAS naming conventions.

To use a variable with a non-conformant name you need to address it as a SAS Name Literal: '<name>'n

proc print data=mydata;
  var 'What is your age?'n; 
run;

 

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

SAS variable names are limited to 32 characters so ideally try to import your data with more suitable variable names that conform to SAS naming conventions.

To use a variable with a non-conformant name you need to address it as a SAS Name Literal: '<name>'n

proc print data=mydata;
  var 'What is your age?'n; 
run;

 

Tom
Super User Tom
Super User

You should put the description (or question text) into the LABEL attached to the variable instead of trying to use it as the NAME of the variable.

 

How did you IMPORT the data?  Did you use PROC IMPORT?

 

If you must use PROC IMPORT then make sure to set the VALIDVARNAME option to V7 before running the PROC IMPORT step so it will make valid SAS names for the variables.

 

Do you have the data in a TEXT file, such as a CSV file?

 

In that case READ the data with your own data step and you can can control the names of the variables, including attaching the descriptive labels.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 849 views
  • 1 like
  • 3 in conversation