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?
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.
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
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.