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.
126 | 0.24 | 46240 | 89.60 |
It will be highly appreciated if you can advise me how to avoid this variable truncation problem.
Thanks
Joon1
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;
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;
Thank you for your kind help, PaigeMiller. It is straightforward, but I couldn't find a relevant posting. Have a great week.
Joon1
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.