BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Quentin
Super User

Hi Paul (et al.)

 

I think perhaps you're being a little bit too harsh on the macro documentation.

https://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n1y2jszlvs4hugn14nooftfrxhp3.htm&docse...

 

With a close reading, it defines three different "forms" of macro variable specification

:macro-variable

:macro-variable-1 − : macro-variable-n <NOTRIM>

:macro-variable SEPARATED BY 'characters ' <NOTRIM>

 

Only the second and third form say that leading and trailing blanks are automatically trimmed (yes should be "stripped").  So that part is accurate.  Definitely it should be updated to describe the <TRIMMED> option which is available for the first form.

 

data have ;
  x="  foo  " ;
run ;

proc sql ;
  select x into :mvar1 from have ;
  select x into :mvar2 trimmed from have ;
  select x into :mvar3- from have ;
  select x into :mvar4- notrim from have ;                   
  select x into :mvar5 separated by " " from have ;
  select x into :mvar6 separated by " " notrim from have ;
quit ;

%put >>&mvar1<< >>&mvar2<< >>&mvar3<< >>&mvar4<< >>&mvar5<< >>&mvar6<< ;

 

Returns:

>>  foo  << >>foo<< >>foo<< >>  foo  << >>foo<< >>  foo  <<

Which is consistent with the docs.

 

In the second form, since the upper bound is optional, I suppose it should be:

:macro-variable-1 −  <: macro-variable-n> <NOTRIM>

 

Kind Regards,

 

--Q.

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
hashman
Ammonite | Level 13

@Quentin;

Quentin, fair enough. 

Best - Paul 

Reeza
Super User
The error message should also be updated to include NOTRIM as an option in the list. Currently it's not shown but TRIMMED is included.

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
  • 17 replies
  • 2221 views
  • 6 likes
  • 8 in conversation