BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello
What is the purpose of  -l in the following code?
What is the difference between DOWNAME9. and weekdate9. formats?

 

data ex2;
ddate_time=datetime();/*today's datetime value for example*/
ddate=datepart(ddate_time);
day_of_week=put(ddate,DOWNAME9.);
day_of_week2=put(ddate,weekdate9. -l);
format ddate_time datetime20.  ddate date9.  ;
run;
3 REPLIES 3
koyelghosh
Lapis Lazuli | Level 10

As per the official documentation on PUT function (as here), I am guessing -L is for left align, -C for centre align and -R for right align. Since you are extracting a weekdate (which is a character), it is right aligned by default. I guess you are overriding that behaviour with -L option.

 

You can do a quick test by substituting -l with -c and -r to see if the alignment changes. If it does then probably that is it. Please let me know the outcome of substituting -l with -c and -r.

 

Thank you

 

koyelghosh
Lapis Lazuli | Level 10

@Ronein Actually I went ahead and played with -L and -R options myself and the results are as per the documentation. Please see the image below. -L aligns to left and -R to the right.

 

L and R option differenceL and R option difference

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1679 views
  • 5 likes
  • 3 in conversation