DATA Step, Macro, Functions and more

Create macro variable using the data

Reply
Frequent Contributor
Frequent Contributor
Posts: 78

Create macro variable using the data

Dear friends,

 

I would like to create macro variable for each group to store # of pats respectively, please see below:

 

such as  &a = 30 , &b = 20  .....  So I can use these numbers in my proc report procedure. 

 

Group    # of pats

a              30

b              20

c              2000

d             150

.               .

.               .

 

May you let me know how I can do it ?

 

Thank you very much, 

Ivy 

Super User
Posts: 19,805

Re: Create macro variable using the data

Use call symputX

 

data _null_;

set have;

call symputx('macrovar'||put(_n_, z2.), variable);

run;

%put &macrovar01.;
%put &macrovar02.;
Frequent Contributor
Frequent Contributor
Posts: 78

Re: Create macro variable using the data

Thank you very much, worked !

 

 

Ask a Question
Discussion stats
  • 2 replies
  • 150 views
  • 0 likes
  • 2 in conversation