BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bal23
Lapis Lazuli | Level 10

DATA _null_; Threshold=250000; call symput('u_Threshold',trim(Threshold)); RUN;

 

Please see above code. I do not understand, since threshold is already hard coded, I do not know why there is the need for trim(thresold).

Anyone gives me the exaplanation?

And what if I replace this with symputx?

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You cannot use PUT.  You must use %PUT.  Then you will see 12 characters appear between the two asterisks.

 

Yes, if you use SYMPUTX you do not need TRIM (or STRIP or LEFT or COMPRESS) ... all leading and trailing blanks will be gone.  You can see that in the same way (with %PUT).

View solution in original post

3 REPLIES 3
Astounding
PROC Star

If you were to examine the value of &U_THRESHOLD, you would find it contains 12 characters:   6 blanks followed by 6 digits.  You can see this easily using:

 

%put *&u_threshold*;

 

Since there are no trailing blanks, TRIM would not affect the result.  However, STRIP would remove both leading and trailing blanks, and would make a difference.

 

The extra blanks get added because the second parameter to CALL SYMPUT is supposed to be a character string.  When a numeric is supplied, it forces SAS to make a numeric-to-character conversion.  You can see that this took place, by reading the log.

 

CALL SYMPUTX would make a difference.  Although it still must perform the numeric-to-character conversion, it also removes the leading blanks that result.  &U_THRESHOLD would be only 6 characters long.  Also, the note in the log about numeric-to-character conversion would disappear when using CALL SYMPUTX.

Bal23
Lapis Lazuli | Level 10

Can you explain?

Do you mean, when I type, "put *&u_threshold*;" I can see it contains 12 characters?

Do you mean, if I use CALL SYMPUTX , I do not need to use "Trim"

Astounding
PROC Star

You cannot use PUT.  You must use %PUT.  Then you will see 12 characters appear between the two asterisks.

 

Yes, if you use SYMPUTX you do not need TRIM (or STRIP or LEFT or COMPRESS) ... all leading and trailing blanks will be gone.  You can see that in the same way (with %PUT).

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2260 views
  • 1 like
  • 2 in conversation