Solved
Contributor
Posts: 40

# How to Mask a Period in Executing a Macro

Dear Community,

My macro is looping through an array of numbers.

%let cutoff = 90 95 96 96.5;

The macro works just fine for the integers, but not for the numbers with decimal marks.  For 96.5, the macro thinks that it is 2 separate numbers - 96 and 5.

The %STR and %NRSTR functions do not mask periods.

How can I make the macro to recognize 96.5 properly?

I think that a masking macro function is needed, but I can't fine one.

Thanks,

Eric

Accepted Solutions
Solution
‎12-23-2013 10:08 PM
Super User
Posts: 8,112

## Re: How to Mask a Period in Executing a Macro

You will need to provide more about how you are using the values.

Perhaps you are using the %SCAN() function?  The default delimiters for %SCAN() do include a period, but you can specify the delimiters you want to use.

%let cutoff = 90 95 96 96.5;

%do i=1 %to %countw(&cutoff,%str( ));

%let value=%scan(&cutoff,&i,%str( ));

...

%end;

All Replies
Posts: 1,147

## Re: How to Mask a Period in Executing a Macro

Hi,

I have created a dummy dataset by using the macro variable with the values provided and it has created a dataset without any problem. Could you please check the below code and let me know if this is not the way you want to use it.

%let cutoff = 90 95 96 96.5;

%put &cutoff;

data have;

array mac(4) (&cutoff);

do i = 1 to 4;

new=mac(i);

output;

end;

run;

Thanks,

Jag

Thanks,
Jag
Solution
‎12-23-2013 10:08 PM
Super User
Posts: 8,112

## Re: How to Mask a Period in Executing a Macro

You will need to provide more about how you are using the values.

Perhaps you are using the %SCAN() function?  The default delimiters for %SCAN() do include a period, but you can specify the delimiters you want to use.

%let cutoff = 90 95 96 96.5;

%do i=1 %to %countw(&cutoff,%str( ));

%let value=%scan(&cutoff,&i,%str( ));

...

%end;

Contributor
Posts: 40

## Re: How to Mask a Period in Executing a Macro

Ahh...yes, thank you, Tom.  I did not specify the delimiter when I used %SCAN().  Once I corrected that with %STR( ), the macro worked.

Thank you!

And thank you, Jagadishkatam, for providing your sample code!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 3 replies
• 766 views
• 3 likes
• 3 in conversation