SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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