BookmarkSubscribeRSS Feed
munitech4u
Quartz | Level 8

How to solve this problem:

 

%let bin371=MARINA, RV PARK, CAMPGROUND;
%put %qleft(&bin371);

 

It is throwing me error "Positional parameters error" .I need to use qleft to remove trailing blanks. How can i Keep this value, and same time remove the trailing blanks.?

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The auto macro %qleft only accepts up to two parameters.  Look at what code your macro is creating:

%put %qleft(MARINA, RV PARK, CAMPGROUND);

You will see in the above there are three parameters as you have used commas in the string.

You could try:

%let bin371=MARINA, RV PARK, CAMPGROUND;
%put %qleft(%quote(&bin371));

However, why bother with the above at all.  Base SAS is designed to process and manipulate data.  Macro SAS is designed to generate code.  The two are for different purposes and trying to shoe horn data processing into macro language is not a good idea.  Put your list in a dataset:

PARAM

MARINA

RV PARK

...

 

And then use that dataset, far easier to code and maintain.

rogerjdeangelis
Barite | Level 11

Hi Team

 

%let bin371='MARINA, RV PARK, CAMPGROUND';
%let res= %qsysfunc(dequote(%left(&bin371)));

%put **&res.**;

**MARINA, RV PARK, CAMPGROUND** 

 

I find this useful,  especially when you have '%', ';' , ','  and  '&' in the text.

 

SAS often does automatic unquoting when you least expect it, so the single quotes let you decide when you want to unquote.

munitech4u
Quartz | Level 8
well, it is a smaller step in one of the loops, that I was using. But this worked fine for me: %sysfunc(strip(&bin371));

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
  • 480 views
  • 0 likes
  • 3 in conversation