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.
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;
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;
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.