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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.