Hi, i have an xls file from which records needs to be extracted for loading to DB table. SAS by default has provided an extraction script which uses XLS engine for importing the data. I require the column names in the excel to be renamed before the extraction script is run. Is there any sas code to rename the column on the file. Any pointers to this would be helpful
You have two possibilities:
- set options validvarname=v7; this will force proc import to create names that comply with SAS standards.
- or use (eg) 'Name of Individual or Entity'n as the variable name in the rename statement.
Use PROC DATASETS. In a MODIFY block for your imported dataset, use the RENAME statement to rename the variables.
Thanks Kurt for the update, got a lead to explore. After importing the excel data into sas dataset, i tried the renaming option but column name contains space between it instead of '_' hence causing the code to fail.
Error: Expecting an =.
is there any way i can rename the column - Name type -> Name_type.
Have attached a screenshot of the column name for reference.
You have two possibilities:
- set options validvarname=v7; this will force proc import to create names that comply with SAS standards.
- or use (eg) 'Name of Individual or Entity'n as the variable name in the rename statement.
Thanks a ton Kurt for the quick response . I tried both approaches and both worked fine .
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.