what would compressing a date give me? just removing any space around?
my command is as follows:
compress(put(intnx('month',"&perfdate."d,0,'end'),monyy6.))
Have you tried it both with and without? The COMPRESS function should not make any difference here.
BTW, when you post code questions, please post complete statements and preferably program steps. Also use the "Insert SAS Code" menu option.
The indicated button has to be used for logs and textual data where it is necessary that the horizontal spacing is kept and no characters are changed. The "little running man" right next to it is meant for posting SAS code, as it additionally provides coloring similar to the SAS Enhanced Editor.
Dates are numbers. COMPRESS() works on character strings.
So to use COMPRESS() with a date value you would first need to convert it into a string.
Your code is using the PUT() function to convert date value generated by the INTNX() function into a character string using the display format specification of MONYY6. Since that will use 3 positions for the month abbreviation that leaves only 3 positions for the year. SAS will truncate the year to just the last two digits by eliminate the century part. This yield only 5 characters which will be right align in the 6 character string that is generated.
You didn't tell COMPRESS() what characters to compress out of the string, so it will default to removing the spaces. Thus the leading space will be removed.
You could eliminate the need for the COMPRESS() function by using MONYY5. format instead of MONYY6. since then there would be no leading space. Or better still use the MONYY7. format and you will have room for all four digits of the year and you still wouldn't have any leading spaces.
PS: Learn what the buttons on the tool bar that appears above the text box of the forum editor do.
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.