My problem is as follows - I have this piece of code that works fine and adds the character saved into the macro variable into the table:
%let year=2015;
data example;
input year $40.;
years=dequote(resolve(quote(year)));
datalines;
&year
;
run;
Now I would like to do the same inside the macro, with the code as follows:
%macro pokus();
%let year=2015;
data example;
input year $40.;
years=dequote(resolve(quote(year)));
datalines;
&year
;
run;
%mend pokus;
%pokus;
Why is it so ? Is there some easy way how to add the macro variable into the table inside the macro ? I need that to perform this type of loop:
%macro pokus();
%do i=2015 %to 2017;
%let year=&i.;
data example;
input year $40.;
years=dequote(resolve(quote(year)));
datalines;
&year
;
run;
....additional code .....
%end;
%mend pokus;
%pokus;
Additional explanation - It is a part of more complex exercise that continues in this way:
data z;
length roky mesic mesic2 saz $100;
input roky mesic mesic2 saz;
datalines;
2012 01 1 k
2012 02 2 h
2012 03 3 j
2012 04 4 x
2012 05 5 l
2012 06 6 m
;
run;
proc sql;
select count (*) into: pocet from z;
quit;
%macro rok();
%do i=1 %to &pocet;
data _null_;
set z (obs= &i);
call symputx("roky",roky);
call symputx("mesic",mesic);
call symputx("mesic2",mesic);
call symputx("saz",saz);
run;
...... additional code .....
%end;
%mend rok;
%rok;
and now I would like to make it dynamic, i.e. first calculate everything with the column "roky" having value 2012, than 2013,2014, e.t.c. But I am not able to build another macro above this construction changing the column "roky" in the z table.
Thank you for any help.