- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am in the middle of data cleaning process and some of the columns in my data set are unnamed. I know how to change already existing name but how to do that with those unnamed? Example I want to name those columns in yeallow circle as: first date as DATE1 and the other as DATE2. How do I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Explain what you are showing us. What SAS interface created this? (Base SAS, Enterprise Guide, University Edition, etc.)
Is this even a SAS data set you are showing?
In SAS, you cannot have variables/columns that are unnamed.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since a SAS data set will never have a variable without a name I find your question extremely odd. It appears that the variables you are referencing are named F4 and F5. One suspects that the data source you read had a blank row before the actual column headings and so you think the first "value" recorded is the variable name. But since those two variables are dates you cannot have a value like "Date1".
I might go back to the source file that you read and examine it carefully. If there is a blank row, or most of the "headers" appear on the second row of the file, delete the blank values on the first row moving the headers into the first row. Then re-import your data.
Once you have a SAS data set you can rename columns in a number of ways, Proc Data sets with a Modify block renaming variables, manually by clicking on column properties in the data set view
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you were right. I tried importing the data set again. I'm importing from xlsx file and I started from the third row. Now the problem is gone. I'm using sas enterprise guide. This code solved my problem.
proc import datafile="D:\filepath\filename.xlsx"
dbms=xlsx
out=test
replace;
range="Sheet1$A3:0";
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would suggest adding the following before your IMPORT. It ensures that your variables are read in with cleaner names for programming.
options validvarname=v7;