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

Dear Madam/Sir,

I created a character variable as below.

if naics in (5412,5413,5417,5418,5414,54161,54162,54169,54191,54193,54199,54192,54194) then IO='5412OP';

However, variable name is truncated at the 5-digit after SAS operation as below.

IO Frequency Percent CumulativeFrequency CumulativePercent
5412O
1260.244624089.60

It will be highly appreciated if you can advise me how to avoid this variable truncation problem.

 

Thanks

Joon1

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Character variables have a specific length (which can be different for each character variable). Your character variable was created to have a length of 5, and so a six character value will be truncated to five characters.

 

You don't show the entire data step where this variable IO is created, however, you need to specify the length so that the longest string that will occur in your data can fit.

 

So when you create such a data set, you can start with

 

data mydataset;
     length io $ 6;
     set ...;
/* Other data step commands go here */
run;

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Character variables have a specific length (which can be different for each character variable). Your character variable was created to have a length of 5, and so a six character value will be truncated to five characters.

 

You don't show the entire data step where this variable IO is created, however, you need to specify the length so that the longest string that will occur in your data can fit.

 

So when you create such a data set, you can start with

 

data mydataset;
     length io $ 6;
     set ...;
/* Other data step commands go here */
run;

 

--
Paige Miller
joon1
Quartz | Level 8

Thank you for your kind help, PaigeMiller. It is straightforward, but I couldn't find a relevant posting. Have a great week.

Joon1

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2628 views
  • 0 likes
  • 2 in conversation