- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am importing a .csv file into SAS that has variable names like "Collection Date", "Patient Result". The variables appear the same in SAS after I import, except I can't call them because I know they actually don't have a space in their name after the import. How do I see what they actually are called? I've tried running :
options validvarname=v7
But that didn't seem to work. I tried the above with =v6, v9, and any and that didn't work.
Thanks!
Clare
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In most (all?) SAS interfaces, there is a Library/data set viewer, and as far as I know its always on the left and if you double-click on a data set in a library, you get to see (a portion of) the data and the column names that way. Scrolling will let you see all of the data and all of the column names.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
VALIDVARNAME controls how variable names are created. V7 means it will use underscore not spaces.
You can use PROC DATASETS/CONTENTS to see variable names but you can also strip the labels off if you'd like.
For a data set, CLASS, in a library called MYLIB the following will strip all labels.
proc datasets lib=mylib memtype=data;
modify class;
attrib _all_ label=' ';
run;
quit;
@claremc wrote:
Hello,
I am importing a .csv file into SAS that has variable names like "Collection Date", "Patient Result". The variables appear the same in SAS after I import, except I can't call them because I know they actually don't have a space in their name after the import. How do I see what they actually are called? I've tried running :
options validvarname=v7But that didn't seem to work. I tried the above with =v6, v9, and any and that didn't work.
Thanks!
Clare
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The Validvarname=V7 means that characters not valid in SAS names will be replaced with _ characters as opposed to Validvarname=Any which would allow spaces and other characters. However you would then have to use name-literals in the code: 'Collection Date'n evertime to use the variable.
When you run proc import data step code is generated and appears in the log with the names of the variables in INFORMAT, FORMAT and INPUT statements.
Here's an idea: write a data step to change the names to what you like. You can copy that generated code and replace "Collection_Date" with "CollectionDate" if that is what you would prefer.
A very useful side effect of modifying the code is that you can set standard lengths/ types for other files of the same structure. Just change the Infile statement to point to a new file and change the name of Data set for output.
Then you will avoid all the problems associated with mismatched variable types or lengths of character variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If these really are the variable names, you can refer to them in your subsequent programming using:
"Collection date"n
The n after the closed quote indicates that this is a name, not a character string in quotes.
The option you used:
validvarname=v7;
will work, but you need that option in place before you import the data, not after.