Is it wrong to write like this in SAS code that you want t to be a string in macro?
%macro hentami(t,data,aar);
data kuhr&aar.;
set kuhr.kuhr_&aar.;
rename pasientlopenummer =lopenummer;
run;
data "&t"kuhr&aar.;
merge &data (in=a) kuhr&aar.;
if a by lopenummer;
uke =round((differansedager -inn_refdager0)7,1);
tjeneste=sum(fastlege,legevakt,spesialist,psykolog);
if uke ge 0 and uke le 52 then output;
run;
%mend;
%hentami_kuhr(ami,ami_index,2008);
I got an error message when I write "&t"kuhr&aar. in macro %hentami_kuhr(t,data,aar) there t is a text, data is a dataset and aar is year (like 2008). How can I rewrite this macro code?
Try modifying it as follows
data &t.kuhr&aar.;
use %str or %nrstr for special charactor.
for example
%Macro Mtest(val);
data sample;
a="&val";
run;
proc print;run;
%Mend;
%Mtest(xxx,yyy)/* error */
%Mtest(%str(xxx,yyy))
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.