Hi, I imported an xls file (with a variable named ‘VAR ONE’) in a dataset work.test
I know that it is not a valid SAS name of variable.
In the dataset the name of the variable is still ‘VAR ONE’, and I can’t use it.
I tried:
Data work.test2 (rename=([VAR ONE]= VAR_ONE));
Set work.test;
Run;
But it doesn’t work.
Can you help me?
Thank you all.
zaghini
If you have the option setting of Validvarname=Any then things like proc import will allow non-standard names. These variable names must be used as a name literal which means the text enclosed in quotes followed by the letter n such as 'Var one'n .
Additionally you can set the option Validvarname=V7; to prevent proc import from creating such names. The V7 option would create variable names with an underscore character, _ , in the place of any non-letter or non-digit character appearing in the data source as a variable name.
If you have the option setting of Validvarname=Any then things like proc import will allow non-standard names. These variable names must be used as a name literal which means the text enclosed in quotes followed by the letter n such as 'Var one'n .
Additionally you can set the option Validvarname=V7; to prevent proc import from creating such names. The V7 option would create variable names with an underscore character, _ , in the place of any non-letter or non-digit character appearing in the data source as a variable name.
I did:
options validvarname=v7;
PROC IMPORT DATAFILE="/…/test.xls" OUT=work.vincolati DBMS=XLS REPLACE;
SHEET="Quadratura collegati";
RUN;
but in xls file I've the variable 'Bilancio 2021' and in work.vincolati I still have the variable 'Bilancio 2021' instead 'Bilancio_2021' that I would expect with the options validvarname=v7.
where am I wrong?
Run PROC CONTENTS. What you see may not be the variable name, but the label.
I’ve done it!
The problem was that I submitted sas code in separated steps:
and does not work.
But if I do it in 2 steps (or 1) it works:
thank you @Kurt_Bremser and @PeterClemmensen and @ballardw
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.