Is there a function or statement that would trim blanks from an imported SQL character variable? e.g. similar to SAS functions STRIP or TRIM.
For example, if use the following code, STRIP has no impact but it doesn't give an error message either:
Proc sql;
select strip(variable_name) as no_blanks
from xxxx_database;
quit;
So, if a character has a set length of 12 but you trim it, it still has a length of 12. Make sure you use, LENGTHN to check the length.
Also, it can be other invisible characters, you can use a hex format to view your data to check. I think 20 is a space and anything else is a different character.
put variable_name $hex.;
Are these leading or trailing blanks? Are you sure they're blanks?
What makes you think it hasn't worked?
Thanks for your reply. Your question puzzled me now, I'm not sure they are blanks!, although when I do proc print they look so.
I created a data set from the SQL statement and used the trim and strip functions in a data statement but looks like the character variables are still the same length with what it looks like a lot of trailing blanks.
I may have to investigate more...
So, if a character has a set length of 12 but you trim it, it still has a length of 12. Make sure you use, LENGTHN to check the length.
Also, it can be other invisible characters, you can use a hex format to view your data to check. I think 20 is a space and anything else is a different character.
put variable_name $hex.;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.