BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am newbie to SAS.
Basically, I have written a few macros in SAS which I would like to activate when different conditons are met.
For example ,I have a do loop and I would like diff macros to be called each time the do loop is incremented.


(Toggle Plain Text)
Data _NULL_

Do i=0 to 10

Select (i)

When (0)%Macro1(var1);
when(2) % macro2(var2);
....
otherwise
end
end
Data _NULL_

Do i=0 to 10

Select (i)

When (0)%Macro1(var1);
when(2) % macro2(var2);
....
otherwise
end
end


However, I found that I cannot do that i.e. select different macros when different conditions are met. Anybody can suggest how I could achieve the same functionality?


Also, is it possible to concatenate 2 macro strings.

i.e. % Let macro1=ABC;
%Let macro2=DEF;

I would like to have
%Let macro 3= ABCDEF; (but using macro1 and 2 since the values may change.)

How can I do this??
Thanks.

(P.S if possible, do explain using code fragments as i am really very new to SAS and may not be aware of some of the "basic"rules of the language)
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
This question isn't about ODS or Base Reporting Procedures (PRINT, REPORT and TABULATE).

There is no better documentation on Macro processing than the Macro reference in the documentation, the SUGI and SGF papers that have been written and the books by users on the topic of macro.

This forum posting, in particular, answers your second question about concatenating macro variables together:
http://support.sas.com/forums/thread.jspa?messageID=7694Ḏ

Your first question (about executing code conditionally using macro processing), besides being off-topic is WAY too big a topic to cover here in the forum.

Here are some links to other forums postings that you may find useful:
http://support.sas.com/forums/thread.jspa?messageID=7089᮱
http://support.sas.com/forums/thread.jspa?messageID=6402ᤂ
http://support.sas.com/forums/thread.jspa?messageID=5697ᙁ

This SUGI paper is particularly helpful:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

For more help, you might consider contacting SAS Tech Support.

cynthia

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