0
votes

I am attempting to format variables in SAS studio which have been truncated due to the name being longer than 32 characters, when I attempt to format the variables in SAS studio it gives the warning 'this variable in uninitialized'. when I run the same code in SAS EG against the same excel document imported, the code works fine and formats the variable. Why would the same code in SAS studio not work?

code:

data test; set test1; format 'variable'n best12.; run;

3
Your question is a little confusing. Are you talking about the names of the variables? In SAS names are limited to 32 characters. Or the values of the variables? In SAS there are two types of variables, fixed length strings and floating point numbers. A FORMAT in SAS is instructions on how to convert the value to strings, usually for presentation in reports. BEST is an example of such a format for numeric variables.Tom
Apologies Tom, reading that again I can see why it is confusing. SAS has truncated the variable names so I am attempting to format the truncated names using 'name'n (as there is white spaces in there also). When I format the variable as a test in EG from the format comma14 to best12 it works fine, copying the code into SAS studio gives the warning 'variable is uninitialized'J.stack
Make sure you are trying to use the variable name and not the label attached to it. PROC IMPORT might have to modify the column headers to create valid and/or unique variable names, but it will use the original column header as the label and many ways of looking at the SAS dataset will display the labels as the column headers instead of using the actual variable names.Tom

3 Answers

1
votes

Compare the value of option VALIDVARNAME in EG vs Studio. Set it in studio to the same as EG.

1
votes

Two common ways to view the current setting of an option. Proc OPTIONS or function GetOption

proc options option=validvarname;
run;

%put %sysfunc(getoption(validvarname));
0
votes

The code won’t be the same because you’re using two different applications with different default settings most likely. As someone else indicated, it’s likely the validvarname option that’s the issue. I would recommend setting it to V7 which avoids these issues. With this setting, SAS converts them to valid variable names by default and you can avoid the rename step entirely.

Supposedly the 32 char limit will be lifted in SAS 9.5. No release date has been announced, SAS 9.4 M5 was recently released so I’m not expecting it super soon.