Hello,
I created a table using Proc Sql and used PUT() to convert numeric value to character. There are two issues that I'm now facing and hoping someone can help me:
1. How can I assign format and informat to those columns with no format and informat?
2. For the column wherein I used put(x,9.), I got 8 spaces + . (dot) for those with no value. How do I replace this to just be simply blank?
Is there a way to incorporate the solution into my proc sql table? If not what's the most efficient way to tackle these issues?
Thank you for your help!
1) character variables need neither a format nor an informat, unless some special recoding is wanted.
2) try options missing = " "; before you do the conversion
1) character variables need neither a format nor an informat, unless some special recoding is wanted.
2) try options missing = " "; before you do the conversion
Also note that using PUT(x,9.) will cause the actual values to be RIGHT ALIGNED. So numbers that only need less than 9 digits to be displayed will have leading spaces. Is that what you want? I noticed from the picture of your PROC CONTENTS output that you are using ODS to display things. That will NOT display the leading spaces, which can lead to confusion then trying to compare values.
You could use Z9. to use leading zeros instead.
You could use 9.-L to generate trailing spaces instead.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.