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

When using EG import wizard, ticking the box "rename columns to comply with SAS naming conventions", SAS will rename all unconventional column names.

 

I want to apply the same logic to all values in a dataset, because those values will be used as reference for some further operations.

But I'm not sure how EG import wizard renames columns. What is the logic?

 

I am only able to pick up some:

  • replace space with underscore, e.g. 'Col Name' > 'Col_Name';
  • then cut it to 32 characters, e.g. 'One_Two_Three_Four_Five_Six_Seven_Nine' > One_Two_Three_Four_Five_Six_Seve';
  • if there are same names, then use number to replace the last character, e.g. 'One_Two_Three_Four_Five_Six_Seve
    ' > 'One_Two_Three_Four_Five_Six_Sev0';

However I believe it is not the whole picture, because I've run a sample test:

/* before */
One Two Three Four Five Six Seven Eight
One Two Three Four Five Six Seven Nine
One_Two_Three_Four_Five_Six_Seven_Nine

/* after */
One_Two_Three_Four_Five_Six_Seve
One_Two_Three_Four_Five_Six_0001
One_Two_Three_Four_Five_Six_Sev0

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Are you implying the data values in one data set are supposed to be the column names in another?

IF that is the case then I wouldn't touch any of this with proc import but would control the variable names with a data step to read the data and then create a custom informat with information from one table to map the values to the desired names.

 

If this is not the case then maybe you should provide some example data values that need this approach as I am somewhat confused.

 

Note that the exact same long variable names may get mapped to different values in different proc import results if the order of the variables changes. Also in the case some column headers where the text for the first 40 or so plus characters are the same you will sometimes get a resulting name of VARXXX where the XXX is the column number because the renaming algorithm just gives up.

 

 

View solution in original post

2 REPLIES 2
ayin
Quartz | Level 8
One way to go around the problem is to create a storage (e.g. macro variable) and then store the value, create an empty dataset using this value as the column name, go through SAS EG import wizard and get the final value. Repeat for each value in the dataset. But it might take too much time.
ballardw
Super User

Are you implying the data values in one data set are supposed to be the column names in another?

IF that is the case then I wouldn't touch any of this with proc import but would control the variable names with a data step to read the data and then create a custom informat with information from one table to map the values to the desired names.

 

If this is not the case then maybe you should provide some example data values that need this approach as I am somewhat confused.

 

Note that the exact same long variable names may get mapped to different values in different proc import results if the order of the variables changes. Also in the case some column headers where the text for the first 40 or so plus characters are the same you will sometimes get a resulting name of VARXXX where the XXX is the column number because the renaming algorithm just gives up.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 1812 views
  • 1 like
  • 2 in conversation