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.;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.