DATA Step, Macro, Functions and more

call variables using a macro

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 127
Accepted Solution

call variables using a macro

Dear Expert,

 

I should do a calculation calculate the difference between two variables:

- dataset_201610

- dataset 201609

 

starting from the point that:

&current.=201610

&prev.=201609

 

How can I flexibly specify the columns using something like:

data_set_"&current."-data_set_"&prev."?

 

Thanks a lot in advance,

SH

 

 


Accepted Solutions
Solution
‎11-14-2016 03:17 AM
PROC Star
Posts: 755

Re: call variables using a macro

[ Edited ]
Posted in reply to Sir_Highbury

Like this? Have simply dropped the ""..

 

data have;
input dataset_201610 dataset_201609;
datalines;
10 5
20 1
;

%let current = 201610;
%let prev    = 201609;

data want;
   set have;
   newvar = dataset_&current-dataset_&prev;
run;

View solution in original post


All Replies
Solution
‎11-14-2016 03:17 AM
PROC Star
Posts: 755

Re: call variables using a macro

[ Edited ]
Posted in reply to Sir_Highbury

Like this? Have simply dropped the ""..

 

data have;
input dataset_201610 dataset_201609;
datalines;
10 5
20 1
;

%let current = 201610;
%let prev    = 201609;

data want;
   set have;
   newvar = dataset_&current-dataset_&prev;
run;
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 176 views
  • 1 like
  • 2 in conversation