BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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