BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

All, 
  This is probably a simple way to achieve what I want but I don't know how to do this. 

  I am importing some data from a csv file using the following code: 

 

	proc import datafile=csv out=System dbms=csv replace; 
/* 		getnames=yes; */   *since imported names have parantheses or special characters;
	run;
	

  As shown in the commented code, I have tried commenting the options of getnames out and tried it with the code turned on. Either ways the imported data set has variables that are not being recognized with the rename option. 

 

 

  When attempting to rename : 

  

data Test1; 
	set Work.System(rename = System Power Output(W) = SystemPowOutInW); 
Run; 

 

 

ERROR 79-322: Expecting a =.
 
ERROR 22-7: Invalid option name =.
 
 When attempting to make subset of dataset 
data Test1; 
	set Work.System(keep = System Power Output(W) = SystemPowOutInW); 
Run; 
ERROR 214-322: Variable name ( is not valid.
ERROR 23-7: Invalid value for the KEEP option.
 
Is there a way to make the column names SAS compliant when importing them from the CSV or can someone demonstrate an example of renaming column names with parantheses and special characters ? 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Set the following option and rerun your import code. 

Options validvarname=V7;

SAS should automatically convert the names into cleaner names. 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

When column names are imported that do not conform to the SAS standard then you can rename them like this:

 

data Test1; 
	set Work.System(rename = ('System Power Output(W)'n = SystemPowOutInW)); 
Run; 
Reeza
Super User

Set the following option and rerun your import code. 

Options validvarname=V7;

SAS should automatically convert the names into cleaner names. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 5595 views
  • 7 likes
  • 3 in conversation