@Wolverine Using below code I'm getting a result with your sample data.
Code run locally on a Windows laptop with SAS9.4M8
What happens if you execute this code in your environment in a fresh new session? Only bit you need to end is the path "c:\temp\...." to something that's suitable for your environment.
data have;
infile datalines dsd dlm=',' truncover;
input DEM_AGE DEM_SEX cohort_flag TM_group;
datalines;
3,1,1,0
2,1,1,1
3,2,1,1
3,2,1,1
3,2,1,0
2,2,1,1
2,1,1,1
3,1,1,1
2,1,1,1
3,2,1,0
2,1,1,0
2,2,1,1
3,2,1,0
2,2,0,
3,2,1,1
3,2,1,1
3,1,1,0
3,2,1,0
2,1,1,0
3,1,1,1
3,2,1,1
3,2,1,0
3,2,1,1
3,2,1,1
3,2,1,1
;
RUN;
proc format library=temp;
value age2grp
1='1:Age Group <65'
2='2:Age Group [65,75)'
3='3:Age Group >=75'
.='Inapplicable/Missing'
;
value sex
1='1:Male'
2='2:Female'
.='Inapplicable/Missing'
;
value yesfmt
1='1:Yes'
2='2:No'
.='Inapplicable/Missing'
;
RUN;
filename tableN url 'https://communities.sas.com/kntur85557/attachments/kntur85557/library/4477/5/tablen_05102022.sas';
/*filename tableN url 'https://communities.sas.com/kntur85557/attachments/kntur85557/library/4477/5/tablen_032020_pharmasug.sas';*/
/*filename tableN url 'https://gist.githubusercontent.com/statgeek/b55d964c99975c2ba23fa771afe616bc/raw/b30d55caf6ec4028f5afed3b260ce86b50419ddb/tablen.sas';*/
%include tableN /source2;
filename mprint "c:\temp\gencode.sas";
options mprint mfile;
%tablen(
data=have
,by=TM_group
,var=DEM_AGE DEM_SEX
,type=2 2, outdoc=C:\temp\test.rtf
);
options nomfile;
The code executes with Warnings!
It appears the code the macro generates changes the environment - like ODS LISTING CLOSE;
Below macro call with option MFILE set will write the generated code to file .../gencode.sas which you could use to further investigate what's happening.
filename mprint "c:\temp\gencode.sas";
options mprint mfile;
%tablen(
data=have
,by=TM_group
,var=DEM_AGE DEM_SEX
,type=2 2, outdoc=C:\temp\test.rtf
);
options nomfile;
... View more