BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

What is the meaning of "-L" in following code and why do we need it?

I see that I get same result without using "-L"

data example;
   x1=201711;/*Numeric date  201711*/
   x2=put(x1,6.);/*char date  201711*/
   x2_way2=put(x1,6.-L);/*char date  201711*/
run;
4 REPLIES 4
Astounding
PROC Star
L = Left

It left-hand justifies the six characters returned by the PUT function. You can explore this by adding:

put '*' x2 char6. '*';
put '*' x2_way2 char6. '*';
Ronein
Meteorite | Level 14

Hello

Thank you for the answer.

I still don;t understand .

In both cases(with and without "-L" I see same result  *201711*

Can you show an example when it effect the result?

 

Kurt_Bremser
Super User

You don't see a difference because the length of the format matches the number of digits, so there are no leading spaces.

Run this as an example:

data example;
   x1=201711; /*Numeric date  201711*/
   x2=put(x1,8.); /*char date  201711*/
   x2_way2=put(x1,8.-L); /*char date  201711*/
   put '*' x2 char8. '*';
   put '*' x2_way2 char8. '*'; 
run;
Astounding
PROC Star
So far so good. Now comes the "explore" part. Try different values for x1, such as 1711 or 20. Other than that, the program can stay the same.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 533 views
  • 0 likes
  • 3 in conversation