BookmarkSubscribeRSS Feed
sasowiczka123
Fluorite | Level 6

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?

sasowiczka123_0-1594825089157.png

 

 

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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
ballardw
Super User

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

sasowiczka123
Fluorite | Level 6

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;
Reeza
Super User
Is it possible what you're seeing there are labels rather than variable names, since you have a variable named Assignee/Applicant First?

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1707 views
  • 2 likes
  • 4 in conversation