BookmarkSubscribeRSS Feed
arnreddy007
Calcite | Level 5

Hello Everyone, I am trying to import a text file which has 151 rows and 3216 variables with help of infile statement in SAS. While I am trying to do the variable names are getting truncated as they are more than 32 characters. I know that SAS will be able to take variable names of length only 32 characters. Is there any work around this or automation? Because I cant manually set the lengths of variables to 45. As I said there hundreds of variables which are more than of 32 characters. Any help is greatly appreciated. 

 

Thanks

4 REPLIES 4
Reeza
Super User

One option is to Import them as Var1, Var2, Var3 and assign labels instead.

 

Unfortunately you do need a systematic way to rename them, such as replace all Function with FN or something otherwise you're stuck doing it manually. If you can show some rules we can probably help with that. 

 

Not helpful now, but I believe SAS is getting rid of this restriction in the next update. 

 


@arnreddy007 wrote:

Hello Everyone, I am trying to import a text file which has 151 rows and 3216 variables with help of infile statement in SAS. While I am trying to do the variable names are getting truncated as they are more than 32 characters. I know that SAS will be able to take variable names of length only 32 characters. Is there any work around this or automation? Because I cant manually set the lengths of variables to 45. As I said there hundreds of variables which are more than of 32 characters. Any help is greatly appreciated. 

 

Thanks


 

SASKiwi
PROC Star

SAS table and variable names are currently limited to 32 characters by design. This applies to all recent SAS versions. SAS has committed to increasing this to 255 characters in the next major SAS release 9.5 which I'm hoping we may see in 2019.

SASKiwi
PROC Star

In case anyone else sees this post, SAS's plans have now changed. SAS 9.5 is no longer happening and SAS Viya will eventually replace SAS 9. There aren't any plans I'm aware of regarding changing the 32 character limit in Viya.

ballardw
Super User

Examples, examples, examples.

 

If your variable names are, as seems common from other questions about files with 1000's of variables, names that contain information such as dates like Sales2017 Sales2018 (or with month and year Sales201701 Sales201702 ) then perhaps the entire data structure should be reconsidered as normalized data with one row per date and an actual date variable lends itself to better processing in general.

 

Or if the names could be considered excessively wordy such as House_Sales_first_quarter_2017 shorter names are moderately obvious.

 

You may  want to think of what you will do next. I know I dislike typing variables names that are only 12 characters frequently. I cannot image coding with "1000's" of variables that are much longer than that.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3645 views
  • 3 likes
  • 4 in conversation