BookmarkSubscribeRSS Feed
sai_12
Calcite | Level 5

Hello everyone

 

At the moment i used import data from file-> importdata to bring data into work lib

I believe that is the reason why created suffix eg: goal,goal_0001,goal_0002 etc



But when i use proc import it gives var1,var2 for duplicated columns can any one let me know how to stop this and give me suffix eg: goal_0001 instead of var1

 

Thank you

1 REPLY 1
ballardw
Super User

If the source file was a text file of any sort, such as CSV or tab delimited then Proc Import wrote data step code in the log.

Copy the code from the Log, clean up such as remove line numbers. Search an replace with the editor "var1" to what ever name you want. This is the best way if you are going to read multiple files with the same structure. Save the code and then when you have the next file change in the input file name and the output data set.

 

You could also write Proc Data sets code to rename the variables in place.

 

Proc Import has no options that will let you modify the names. Typically I see "Var1" when one of two things happens: 1) there is not column header to use for a variable name or 2) the header is longer than 32 characters long and matches another column heading for the first 32 characters.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 746 views
  • 0 likes
  • 2 in conversation