BookmarkSubscribeRSS Feed
afs
Calcite | Level 5 afs
Calcite | Level 5

 

 

%macro draft(set1,table1,Lable1);

  %if &set1=1   %then %do;

  proc freq data=dataset;

  set &table1;

  run;

 %end;

 

%else %do;

 proc means data=sasdata.dataset ;

  var &table1;

  run;

 %end;

 %mend draft;

 

I want to get the macro for each of the variables i.e week and accessories

I should be able to get either freq or means report for above-mentioned variables.My code is below .

But seems i am missing something.can anybody advise?

 

 %macro draft;

%means(dataset,week);

%freq(dataset,accessories);

 

%mend draft;

 

2 REPLIES 2
Kurt_Bremser
Super User

Your original macro won't work, because you use &table1 as a dataset in one place and a variable list in another.

Hint: get your steps working without macro code, then replace the future dynamic parts with macro variables, then wrap into a macro definition, and then add macro logic (%if). Test at every step of the development, and thoroughly look at the log. Do a google search for each log message you do not understand.

 

If you run into obstacles you can't overcome, post test data (data step with datalines) and the log.

Cynthia_sas
SAS Super FREQ

Hi:

  These papers outline the basic process of starting with working code and then converting your code to a Macro program:

http://www2.sas.com/proceedings/sugi28/056-28.pdf 

https://support.sas.com/resources/papers/proceedings13/120-2013.pdf 

 

cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 705 views
  • 1 like
  • 3 in conversation