BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi
i have to remove the leading and trailing space in the value of macro variable.
i am working in SAS DI studio.
i have tried %trim()....it is not working ...whereas it is working fine in Base SAS.


please i need help...
1 REPLY 1
Patrick
Opal | Level 21
Hi

You're always using "Base SAS" no matter how you execute the code.

If this is a macro variable created in a autoexec then there might be a difference between a SAS DI session (like SAS EG created by the Object Spawner) and a PC SAS session - and you might not have fully access to this macro var from within the session (as soon as you batch the job you will have full access).

I can be wrong here but I think that strings assigned to macro vars are always stripped of leading and trailing blanks.

What could be is that you're string is quoted - and an %unquote() could solve the problem.

Have a look at the following example:
%let TESTVAR1= xxx y ;
%put TESTVAR1 unquoted: Length is: %length(&TESTVAR1), Value is: &TESTVAR1;

%let TESTVAR2=%quote( xxx y );
%put TESTVAR2 quoted: Length is: %length(&TESTVAR2), Value is: &TESTVAR2;

%let TESTVAR3=%quote( xxx y );
%let TESTVAR3=%trim(&TESTVAR3);
%put TESTVAR3 quoted/trim: Length is: %length(&TESTVAR3), Value is: &TESTVAR3;

%let TESTVAR4=%quote( xxx y );
%let TESTVAR4=%unquote(&TESTVAR4);
%put TESTVAR4 quoted/unquoted: Length is: %length(&TESTVAR4), Value is: &TESTVAR4;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 1005 views
  • 0 likes
  • 2 in conversation