Hello
I've written code that creates multiple PDF pages of graphs, but I'm now looking to see if there's a way to combine the sheets in SAS. Below is my code. The first proc and datastep are setting up the chi-square statistics that will go into the graph footnotes. After that, I set up 6 graphs per page. I have 18 pages (macro_1 to macro_18) that I would prefer to combine in SAS if possible. I tried to add an additional ods pdf file that opens before the graphs and ends after them, but all my formatting in between is lost.
Thanks!
%macro proc_code(var,i,title);
ods output chisq=chi&i;
proc freq data=pd.griffin_collapsed_values;
tables &var*(gender agecat_coll race_coll edu_coll2 income_coll2
employ_coll2)/chisq;
where &var not in (.,99);
run;
quit;
data _null_;set chi&i;
format tmp $40.;
if Statistic="Chi-Square" and Table="Table &var * Gender"
then do;
tmp1=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chia&i",tmp1, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * agecat_coll"
then do;
tmp2=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chib&i",tmp2, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * race_coll"
then do;
tmp3=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chic&i",tmp3, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * edu_coll2"
then do;
tmp4=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chid&i",tmp4, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * income_coll2"
then do;
tmp5=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chie&i",tmp5, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * employ_coll2"
then do;
tmp6=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chif&i",tmp6, 'G');
end;
RUN;
***************************************************************************;
GOPTIONS RESET=ALL ftext="Albany AMT";
ods pdf file="\\vmware-host\Shared Folders\Documents\My Documents\PreDict\Hospital Reports\macro_&i .pdf" startpage=never ;
goptions htitle=11pt;
options nodate nonumber;
options leftmargin=0.5in rightmargin=0.5in;
proc gslide;
title1 "Q&i. &title" lspace=.5in f="bold";
run;quit;
*Bar chart #1;
goptions horigin=0 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=gender
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var not =. and &var ne 99 and gender in (1,2);
format gender genderf. &var yesno.;
title1 "Gender" f="bold" ;
footnote1 j=c h=.75 f=Albany "&chia&i";
run;
quit;
*Bar chart #2;
goptions horigin=4.5 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=agecat_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format agecat_coll agec. &var yesno.;
title1 "Age Categories" f=bold;
footnote1 j=c h=.75 f=Albany "&chib&i";
run;
quit;
*Bar chart #3;
goptions horigin=0 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 240 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=race_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format race_coll racec. &var yesno.;
title1 "Race" f=bold;
footnote1 j=c h=.75 f=Albany "&chic&i";
run;
quit;
*Bar chart #4;
goptions horigin=4.5 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=edu_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99 and edu_coll2 ne .;
format edu_coll2 educc. &var yesno.;
title1 "Education" f=bold;
footnote1 j=c h=.75 f=Albany "&chid&i";
run;
quit;
*Bar chart #5;
goptions horigin=0 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=income_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format income_coll2 incc. &var yesno.;
title1 "Income" f=bold;
footnote1 j=c h=.75 f=Albany "&chie&i";
run;
quit;
*Bar chart #6;
goptions horigin=4.5 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=employ_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format employ_coll2 empc. &var yesno.;
title1 "Employment" f=bold;
footnote1 j=c h=.75 f=Albany "&chif&i";
run;
quit;
ods pdf close;
title;
footnote;
%mend;
%proc_code( discuss_pay,1,Hospital personnel came to my room to discuss payment );
%proc_code( doc_language,2,All hospital documents were available in the language I prefer to read );
%proc_code( undstd_docs,3,I understood all the documents I was asked to sign );
%proc_code( undstd_role,4,I understood the role of all hospital personnel entering my room );
%proc_code( questions_hosp,5, Someone explained what I should do if I had questions after leaving the hospital);
%proc_code( comf_read_write,6,Someone asked me how comfortable I am reading and writing in English );
%proc_code( mt_affordmeds,7,A doctor asked me if I could afford my discharge medication );
%proc_code( mt_DNR,8,A doctor and I talked about whether I would want them to try to save me if my heart stopped );
%proc_code( mt_responsib,9,A doctor asked me if I had any responsibilities that would make me need to leave the hospital as soon as possible (for example, child care, work) );
%proc_code( mt_negcom,10, I heard the doctors make negative comments about me);
%proc_code( nt_negcom,11, I heard the nurses make negative comments about me);
%proc_code( ss_negcom,12,I heard the support staff make negative comments about me );
%proc_code( mt_follow_dcins,13,The doctors asked if my day-to-day routine would prevent me from following their discharge care instructions );
%proc_code( mt_takemed,14, The doctors asked if I was taking my medication regularly before coming to the hospital);
%proc_code( mt_fakesymp,15,The doctors told me I was exaggerating or faking my symptoms );
%proc_code( hosp_rules,16,My friends and family had trouble seeing me because of hospital rules );
%proc_code( ss_unattended,17,I was left unattended for a long time when I was taken to have a test );
%proc_code( mt_seniorphys,18,The senior/attending doctor came to see me every day );
Basically after the PDF's are generated then SAS is done with them.
If you want to create multiple graphs and/or tables and have them in a single PDF document then remove the ODS pdf bits from your macro (don't forget the CLOSE statement) and put all of the macro calls within a single ODS PDF sandwich.
ods PDF File= "<filestuf>.pdf" <pdf options>;
%proc_code( discuss_pay,1,Hospital personnel came to my room to discuss payment );
%proc_code( doc_language,2,All hospital documents were available in the language I prefer to read );
%proc_code( undstd_docs,3,I understood all the documents I was asked to sign );
%proc_code( undstd_role,4,I understood the role of all hospital personnel entering my room );
%proc_code( questions_hosp,5, Someone explained what I should do if I had questions after leaving the hospital);
%proc_code( comf_read_write,6,Someone asked me how comfortable I am reading and writing in English );
%proc_code( mt_affordmeds,7,A doctor asked me if I could afford my discharge medication );
%proc_code( mt_DNR,8,A doctor and I talked about whether I would want them to try to save me if my heart stopped );
%proc_code( mt_responsib,9,A doctor asked me if I had any responsibilities that would make me need to leave the hospital as soon as possible (for example, child care, work) );
%proc_code( mt_negcom,10, I heard the doctors make negative comments about me);
%proc_code( nt_negcom,11, I heard the nurses make negative comments about me);
%proc_code( ss_negcom,12,I heard the support staff make negative comments about me );
%proc_code( mt_follow_dcins,13,The doctors asked if my day-to-day routine would prevent me from following their discharge care instructions );
%proc_code( mt_takemed,14, The doctors asked if I was taking my medication regularly before coming to the hospital);
%proc_code( mt_fakesymp,15,The doctors told me I was exaggerating or faking my symptoms );
%proc_code( hosp_rules,16,My friends and family had trouble seeing me because of hospital rules );
%proc_code( ss_unattended,17,I was left unattended for a long time when I was taken to have a test );
%proc_code( mt_seniorphys,18,The senior/attending doctor came to see me every day
ods pdf close.
I amended my code as suggested (see below), but only the last page was output. All previous ones were overwritten, it seems.
%macro proc_code(var,i,title);
proc freq data=pd.griffin_collapsed_values noprint;
tables &var*(gender agecat_coll race_coll edu_coll2 income_coll2
employ_coll2)/chisq out=chi&i;
where &var not in (.,99);
run;
quit;
*Create macro variable containing Chi-Square Results for each demographic variable;
data _null_;set chi&i;
format tmp $40.;
if Statistic="Chi-Square" and Table="Table &var * Gender"
then do;
tmp1=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chia&i",tmp1, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * agecat_coll"
then do;
tmp2=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chib&i",tmp2, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * race_coll"
then do;
tmp3=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chic&i",tmp3, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * edu_coll2"
then do;
tmp4=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chid&i",tmp4, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * income_coll2"
then do;
tmp5=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chie&i",tmp5, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * employ_coll2"
then do;
tmp6=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chif&i",tmp6, 'G');
end;
RUN;
***************************************************************************;
GOPTIONS RESET=ALL ftext="Albany AMT";
goptions htitle=11pt;
options nodate nonumber;
options leftmargin=0.5in rightmargin=0.5in;
proc gslide;
title1 "Q&i. &title" lspace=.5in f="bold";
run;quit;
*Bar chart #1;
goptions horigin=0 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=gender
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var not =. and &var ne 99 and gender in (1,2);
format gender genderf. &var yesno.;
title1 "Gender" f="bold" ;
footnote1 j=c h=.75 f=Albany "&chia&i";
run;
quit;
*Bar chart #2;
goptions horigin=4.5 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=agecat_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format agecat_coll agec. &var yesno.;
title1 "Age Categories" f=bold;
footnote1 j=c h=.75 f=Albany "&chib&i";
run;
quit;
*Bar chart #3;
goptions horigin=0 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 240 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=race_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format race_coll racec. &var yesno.;
title1 "Race" f=bold;
footnote1 j=c h=.75 f=Albany "&chic&i";
run;
quit;
*Bar chart #4;
goptions horigin=4.5 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=edu_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99 and edu_coll2 ne .;
format edu_coll2 educc. &var yesno.;
title1 "Education" f=bold;
footnote1 j=c h=.75 f=Albany "&chid&i";
run;
quit;
*Bar chart #5;
goptions horigin=0 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=income_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format income_coll2 incc. &var yesno.;
title1 "Income" f=bold;
footnote1 j=c h=.75 f=Albany "&chie&i";
run;
quit;
*Bar chart #6;
goptions horigin=4.5 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=employ_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format employ_coll2 empc. &var yesno.;
title1 "Employment" f=bold;
footnote1 j=c h=.75 f=Albany "&chif&i";
run;
quit;
title;
footnote;
%mend;
ods pdf file="\\vmware-host\Shared Folders\Documents\My Documents\PreDict\Hospital Reports\macro_a.pdf" startpage=never ;
%proc_code( discuss_pay,1,Hospital personnel came to my room to discuss payment );
%proc_code( doc_language,2,All hospital documents were available in the language I prefer to read );
%proc_code( undstd_docs,3,I understood all the documents I was asked to sign );
%proc_code( undstd_role,4,I understood the role of all hospital personnel entering my room );
%proc_code( questions_hosp,5, Someone explained what I should do if I had questions after leaving the hospital);
%proc_code( comf_read_write,6,Someone asked me how comfortable I am reading and writing in English );
%proc_code( mt_affordmeds,7,A doctor asked me if I could afford my discharge medication );
%proc_code( mt_DNR,8,A doctor and I talked about whether I would want them to try to save me if my heart stopped );
%proc_code( mt_responsib,9,A doctor asked me if I had any responsibilities that would make me need to leave the hospital as soon as possible (for example, child care, work) );
%proc_code( mt_negcom,10, I heard the doctors make negative comments about me);
%proc_code( nt_negcom,11, I heard the nurses make negative comments about me);
%proc_code( ss_negcom,12,I heard the support staff make negative comments about me );
%proc_code( mt_follow_dcins,13,The doctors asked if my day-to-day routine would prevent me from following their discharge care instructions );
%proc_code( mt_takemed,14, The doctors asked if I was taking my medication regularly before coming to the hospital);
%proc_code( mt_fakesymp,15,The doctors told me I was exaggerating or faking my symptoms );
%proc_code( hosp_rules,16,My friends and family had trouble seeing me because of hospital rules );
%proc_code( ss_unattended,17,I was left unattended for a long time when I was taken to have a test );
%proc_code( mt_seniorphys,18,The senior/attending doctor came to see me every day );
ods pdf close;
Are you sure? Did you re-run the macro definition as well?
Yes - i reran the whole thing. In addition, removing the ods output of the chi-square resulted in the output datasets prevented the chisquare datasets from being created.
Rather, the datasets were created, but merely contained 2X2 tables. Not the chi square dataset that "ods output chisq=chi&i;" created.
Why did you remove it?
Can you post sample data so we can run this? There's a lot of code there so hard to pinpoint.
Otherwise the binary debugging steps.
1. Remove half of code and run. If error persists try other half of code.
2. Assuming only one half of code generated error - repeat until issue is found.
3 . Since your code is repetitive I would do this with my option statements instead until I found the issue.
You removed it to keep it from going to PDF -> use ODS select none/all to still generate ODS table but keep it from outputting to PDF file.
i'm attaching sample data (excel) to this message - enough to run the macro twice. And here is the code. I wasn't successful with ods select none, but i think that's my own user error. Really appreciate your help.
%macro proc_code(var,i,title);
proc freq data=pd.griffin_collapsed_values noprint;
tables &var*(gender agecat_coll race_coll edu_coll2 income_coll2
employ_coll2)/chisq out=chi&i ;
where &var not in (.,99);
run;
quit;
*Create macro variable containing Chi-Square Results for each demographic variable;
data _null_;set chi&i;
format tmp $40.;
if Statistic="Chi-Square" and Table="Table &var * Gender"
then do;
tmp1=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chia&i",tmp1, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * agecat_coll"
then do;
tmp2=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chib&i",tmp2, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * race_coll"
then do;
tmp3=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chic&i",tmp3, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * edu_coll2"
then do;
tmp4=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chid&i",tmp4, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * income_coll2"
then do;
tmp5=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chie&i",tmp5, 'G');
end;
if Statistic="Chi-Square" and Table="Table &var * employ_coll2"
then do;
tmp6=cat("Chi-Square Results CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob <.001,"<.001",strip(round(prob,.001))));
call symputx("chif&i",tmp6, 'G');
end;
RUN;
***************************************************************************;
GOPTIONS RESET=ALL ftext="Albany AMT";
goptions htitle=11pt;
options nodate nonumber;
options leftmargin=0.5in rightmargin=0.5in;
proc gslide;
title1 "Q&i. &title" lspace=.5in f="bold";
run;quit;
*Bar chart #1;
goptions horigin=0 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=gender
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var not =. and &var ne 99 and gender in (1,2);
format gender genderf. &var yesno.;
title1 "Gender" f="bold" ;
footnote1 j=c h=.75 f=Albany "&chia&i";
run;
quit;
*Bar chart #2;
goptions horigin=4.5 vorigin=6.75 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=agecat_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format agecat_coll agec. &var yesno.;
title1 "Age Categories" f=bold;
footnote1 j=c h=.75 f=Albany "&chib&i";
run;
quit;
*Bar chart #3;
goptions horigin=0 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 240 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=race_coll
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format race_coll racec. &var yesno.;
title1 "Race" f=bold;
footnote1 j=c h=.75 f=Albany "&chic&i";
run;
quit;
*Bar chart #4;
goptions horigin=4.5 vorigin=3.5 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=edu_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99 and edu_coll2 ne .;
format edu_coll2 educc. &var yesno.;
title1 "Education" f=bold;
footnote1 j=c h=.75 f=Albany "&chid&i";
run;
quit;
*Bar chart #5;
goptions horigin=0 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=income_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=6
coutline=white;
where &var ne . and &var ne 99;
format income_coll2 incc. &var yesno.;
title1 "Income" f=bold;
footnote1 j=c h=.75 f=Albany "&chie&i";
run;
quit;
*Bar chart #6;
goptions horigin=4.5 vorigin=0 hsize=3 vsize=3 htext=7pt htitle=9pt ftitle="bold" gsfmode=append;
axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to 220 by 40) minor=none;
axis2 label=none value=none;
axis3 label=none ;
legend1
label=("Response" h=2 pt position=left j=c)
position=(top inside left) mode=share;
pattern1 v=solid color=CX93BFBF;
pattern2 v=solid color=CX4791ED;
proc gchart data=pd.griffin_collapsed_values;
vbar &var/DISCRETE
OUTSIDE=PERCENT
G100
GROUP=employ_coll2
SUBGROUP=&var
RAXIS=axis1
maxis=axis2
gaxis=axis3
legend=legend1
space=0
width=5
coutline=white;
where &var ne . and &var ne 99;
format employ_coll2 empc. &var yesno.;
title1 "Employment" f=bold;
footnote1 j=c h=.75 f=Albany "&chif&i";
run;
quit;
title;
footnote;
%mend;
ods pdf file="\\vmware-host\Shared Folders\Documents\My Documents\test.pdf" startpage=never ;
%proc_code( discuss_pay,1,Hospital personnel came to my room to discuss payment );
%proc_code(undstd_docs,2,All hospital documents were available in the language I prefer to read );
ods pdf close;
I can't run your code, I only have SAS UE which doesn't support GCHART or SAS/GRAPHICS.
Hopefully someone else will be able to help.
Here's the proc freq that should work, you have to remove the NOPRINT option to 'generate' the table.
ods select none;
proc freq data=pd.griffin_collapsed_values;
tables &var*(gender agecat_coll race_coll edu_coll2 income_coll2
employ_coll2);
where &var not in (.,99);
ods output oneWayFreqs=chi&i;
run;
ods select all;
PS, if you can switch to SG procedures, in general they have better options and graph quality.
That proc freq didn't work for me - I received the following warning, and no datasets were created:
WARNING: Output 'oneWayFreqs' was not created. Make sure that
the output object name, label, or path is spelled
correctly. Also, verify that the appropriate
procedure options are used to produce the requested
output object. For example, verify that the NOPRINT
option is not used.
when i replaced oneWayFreqs with chisq, it worked.
Yeah, it does help if you use the correct table name 😉
I would also move the following to outside your macro:
GOPTIONS RESET=ALL ftext="Albany AMT";
goptions htitle=11pt;
options nodate nonumber;
options leftmargin=0.5in rightmargin=0.5in;
Honestly after reading your code, it really should work. I would restart SAS and see if a fresh start helps.
Remove all your graph codes except for one and if you can post that run with the log I'm curious to see what it says. Use options mprint and symbolgen to allow for better debugging.
After running as suggested, only the first page is output. Below is the log - there are a number of warning relating to formatting, but I don't see anything else:
381
382 %macro proc_code(var,i,title);
383 ods select none;
384 proc freq data=pd.griffin_collapsed_values;
385 tables &var*(gender agecat_coll race_coll edu_coll2
385! income_coll2
386 employ_coll2)/chisq;
387 where &var not in (.,99);
388 ods output chisq=chi&i;
389 run;
390 ods select all;
391
392
393 *Create macro variable containing Chi-Square Results for
393! each demographic variable;
394 data _null_;set chi&i;
395 format tmp $40.;
396 if Statistic="Chi-Square" and Table="Table &var *
396! Gender"
397 then do;
398 tmp1=cat("Chi-Square Results
398! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
398! <.001,"<.001",strip(round(prob,.001))));
399 call symputx("chia&i",tmp1, 'G');
400 end;
401 if Statistic="Chi-Square" and Table="Table &var *
401! agecat_coll"
402 then do;
403 tmp2=cat("Chi-Square Results
403! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
403! <.001,"<.001",strip(round(prob,.001))));
404 call symputx("chib&i",tmp2, 'G');
405 end;
406 if Statistic="Chi-Square" and Table="Table &var *
406! race_coll"
407 then do;
408 tmp3=cat("Chi-Square Results
408! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
408! <.001,"<.001",strip(round(prob,.001))));
409 call symputx("chic&i",tmp3, 'G');
410 end;
411 if Statistic="Chi-Square" and Table="Table &var *
411! edu_coll2"
412 then do;
413 tmp4=cat("Chi-Square Results
413! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
413! <.001,"<.001",strip(round(prob,.001))));
414 call symputx("chid&i",tmp4, 'G');
415 end;
416 if Statistic="Chi-Square" and Table="Table &var *
416! income_coll2"
417 then do;
418 tmp5=cat("Chi-Square Results
418! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
418! <.001,"<.001",strip(round(prob,.001))));
419 call symputx("chie&i",tmp5, 'G');
420 end;
421 if Statistic="Chi-Square" and Table="Table &var *
421! employ_coll2"
422 then do;
423 tmp6=cat("Chi-Square Results
423! CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
423! <.001,"<.001",strip(round(prob,.001))));
424 call symputx("chif&i",tmp6, 'G');
425 end;
426 RUN;
427
428 ***********************************************************
428! ****************;
429
430 proc gslide;
431 title1 "Q&i. &title" lspace=.5in f="bold";
432 run;quit;
433
434 *Bar chart #1;
435
436 goptions horigin=0 vorigin=6.75 hsize=3 vsize=3 htext=7pt
436! htitle=9pt ;
437 axis1 label=(a=90 f="Albany AMT" "Frequency") order=(0 to
437! 220 by 40) minor=none;
438 axis2 label=none value=none;
439 axis3 label=none ;
440 legend1
441 label=("Response" h=2 pt position=left j=c)
442 position=(top inside left) mode=share;
443 pattern1 v=solid color=CX93BFBF;
444 pattern2 v=solid color=CX4791ED;
445
446 proc gchart data=pd.griffin_collapsed_values;
447 vbar &var/DISCRETE
448 OUTSIDE=PERCENT
449 G100
450 GROUP=gender
451 SUBGROUP=&var
452 RAXIS=axis1
453 maxis=axis2
454 gaxis=axis3
455 legend=legend1
456 space=0
457 width=6
458 coutline=white;
459 where &var not =. and &var ne 99 and gender in (1,2);
460 format gender genderf. &var yesno.;
461 title1 "Gender" ;
462 footnote1 j=c h=.75 f=Albany "&chia&i";
463 run;
464 quit;
465
466 title;
467 footnote;
468
469 %mend;
470 ods pdf file="\\vmware-host\Shared Folders\Documents\My
470! Documents\PreDict\Hospital Reports\macro_a.pdf"
470! startpage=never ;
NOTE: Writing ODS PDF output to DISK destination
"\\vmware-host\Shared Folders\Documents\My
Documents\PreDict\Hospital Reports\macro_a.pdf",
printer "PDF".
471
472 GOPTIONS RESET=ALL ftext="Albany AMT";
473 goptions htitle=11pt;
474 options nodate nonumber;
475 options leftmargin=0.5in rightmargin=0.5in;
476 options mprint symbolgen;
477 %proc_code( discuss_pay,1,Hospital personnel came to my
477! room to discuss payment );
MPRINT(PROC_CODE): ods select none;
MPRINT(PROC_CODE): proc freq data=pd.griffin_collapsed_values;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): tables discuss_pay*(gender agecat_coll
race_coll edu_coll2 income_coll2 employ_coll2)/chisq;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): where discuss_pay not in (.,99);
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): ods output chisq=chi1;
MPRINT(PROC_CODE): run;
NOTE: The data set WORK.CHI1 has 40 observations and 5
variables.
NOTE: There were 254 observations read from the data set
PD.GRIFFIN_COLLAPSED_VALUES.
WHERE discuss_pay not in (., 99);
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
MPRINT(PROC_CODE): ods select all;
MPRINT(PROC_CODE): *Create macro variable containing
Chi-Square Results for each demographic variable;
MPRINT(PROC_CODE): data _null_;
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): set chi1;
MPRINT(PROC_CODE): format tmp $40.;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * Gender" then do;
MPRINT(PROC_CODE): tmp1=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chia1",tmp1, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * agecat_coll" then do;
MPRINT(PROC_CODE): tmp2=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chib1",tmp2, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * race_coll" then do;
MPRINT(PROC_CODE): tmp3=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chic1",tmp3, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * edu_coll2" then do;
MPRINT(PROC_CODE): tmp4=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chid1",tmp4, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * income_coll2" then do;
MPRINT(PROC_CODE): tmp5=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chie1",tmp5, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
discuss_pay * employ_coll2" then do;
MPRINT(PROC_CODE): tmp6=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 1
MPRINT(PROC_CODE): call symputx("chif1",tmp6, 'G');
MPRINT(PROC_CODE): end;
MPRINT(PROC_CODE): RUN;
NOTE: Numeric values have been converted to character
values at the places given by: (Line):(Column).
3:41 5:63 6:92 7:113 9:164 10:191
NOTE: Variable tmp is uninitialized.
NOTE: There were 40 observations read from the data set
WORK.CHI1.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MPRINT(PROC_CODE):
****************************************************************
***********;
MPRINT(PROC_CODE): proc gslide;
SYMBOLGEN: Macro variable I resolves to 1
SYMBOLGEN: Macro variable TITLE resolves to Hospital personnel
came to my room to discuss payment
MPRINT(PROC_CODE): title1 "Q1 Hospital personnel came to my
room to discuss payment" lspace=.5in f="bold";
MPRINT(PROC_CODE): run;
NOTE: 5929 bytes written to
C:\Users\bt24\AppData\Local\Temp\1\SAS Temporary
Files\_TD4600_MW25F6B917-VMW_\gslide4.png.
MPRINT(PROC_CODE): quit;
NOTE: PROCEDURE GSLIDE used (Total process time):
real time 0.14 seconds
cpu time 0.12 seconds
MPRINT(PROC_CODE): *Bar chart #1;
NOTE: No units specified for the HORIGIN option. INCHES will
be used.
NOTE: No units specified for the VORIGIN option. INCHES will
be used.
NOTE: No units specified for the HSIZE option. INCHES will be
used.
NOTE: No units specified for the VSIZE option. INCHES will be
used.
MPRINT(PROC_CODE): goptions horigin=0 vorigin=6.75 hsize=3
vsize=3 htext=7pt htitle=9pt ;
MPRINT(PROC_CODE): axis1 label=(a=90 f="Albany AMT"
"Frequency") order=(0 to 220 by 40) minor=none;
MPRINT(PROC_CODE): axis2 label=none value=none;
MPRINT(PROC_CODE): axis3 label=none ;
MPRINT(PROC_CODE): legend1 label=("Response" h=2 pt
position=left j=c) position=(top inside left) mode=share;
MPRINT(PROC_CODE): pattern1 v=solid color=CX93BFBF;
MPRINT(PROC_CODE): pattern2 v=solid color=CX4791ED;
MPRINT(PROC_CODE): proc gchart
data=pd.griffin_collapsed_values;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): vbar discuss_pay/DISCRETE OUTSIDE=PERCENT
G100 GROUP=gender SUBGROUP=discuss_pay RAXIS=axis1 maxis=axis2
gaxis=axis3 legend=legend1 space=0 width=6 coutline=white;
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): where discuss_pay not =. and discuss_pay
ne 99 and gender in (1,2);
SYMBOLGEN: Macro variable VAR resolves to discuss_pay
MPRINT(PROC_CODE): format gender genderf. discuss_pay yesno.;
MPRINT(PROC_CODE): title1 "Gender" ;
WARNING: Apparent symbolic reference CHIA not resolved.
SYMBOLGEN: Macro variable I resolves to 1
SYMBOLGEN: Macro variable CHIA1 resolves to Chi-Square Results
CHISQ(1)=0.57 p0.452
MPRINT(PROC_CODE): footnote1 j=c h=.75 f=Albany "Chi-Square
Results CHISQ(1)=0.57 p0.452";
MPRINT(PROC_CODE): run;
WARNING: The VBAR/VBAR3D chart for discuss_pay could not be
labeled because the labels are wider than the bars.
WARNING: There is not enough room for even one legend entry and
the label.
WARNING: The legend has been suppressed.
NOTE: Foreground color WHITE same as background. Part of your
graph might not be visible.
NOTE: 5062 bytes written to
C:\Users\bt24\AppData\Local\Temp\1\SAS Temporary
Files\_TD4600_MW25F6B917-VMW_\gchart14.png.
MPRINT(PROC_CODE): quit;
NOTE: There were 250 observations read from the data set
PD.GRIFFIN_COLLAPSED_VALUES.
WHERE discuss_pay not in (., 99) and gender in (1, 2);
NOTE: PROCEDURE GCHART used (Total process time):
real time 0.34 seconds
cpu time 0.25 seconds
MPRINT(PROC_CODE): title;
MPRINT(PROC_CODE): footnote;
478 %proc_code( doc_language,2,All hospital documents were
478! available in the language I prefer to read );
MPRINT(PROC_CODE): ods select none;
MPRINT(PROC_CODE): proc freq data=pd.griffin_collapsed_values;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): tables doc_language*(gender agecat_coll
race_coll edu_coll2 income_coll2 employ_coll2)/chisq;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): where doc_language not in (.,99);
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): ods output chisq=chi2;
MPRINT(PROC_CODE): run;
NOTE: The data set WORK.CHI2 has 40 observations and 5
variables.
NOTE: There were 256 observations read from the data set
PD.GRIFFIN_COLLAPSED_VALUES.
WHERE doc_language not in (., 99);
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
MPRINT(PROC_CODE): ods select all;
MPRINT(PROC_CODE): *Create macro variable containing
Chi-Square Results for each demographic variable;
MPRINT(PROC_CODE): data _null_;
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): set chi2;
MPRINT(PROC_CODE): format tmp $40.;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * Gender" then do;
MPRINT(PROC_CODE): tmp1=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chia2",tmp1, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * agecat_coll" then do;
MPRINT(PROC_CODE): tmp2=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chib2",tmp2, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * race_coll" then do;
MPRINT(PROC_CODE): tmp3=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chic2",tmp3, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * edu_coll2" then do;
MPRINT(PROC_CODE): tmp4=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chid2",tmp4, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * income_coll2" then do;
MPRINT(PROC_CODE): tmp5=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chie2",tmp5, 'G');
MPRINT(PROC_CODE): end;
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): if Statistic="Chi-Square" and Table="Table
doc_language * employ_coll2" then do;
MPRINT(PROC_CODE): tmp6=cat("Chi-Square Results
CHISQ","(",DF,")=",round(value,.01)," p",ifc(prob
<.001,"<.001",strip(round(prob,.001))));
SYMBOLGEN: Macro variable I resolves to 2
MPRINT(PROC_CODE): call symputx("chif2",tmp6, 'G');
MPRINT(PROC_CODE): end;
MPRINT(PROC_CODE): RUN;
NOTE: Numeric values have been converted to character
values at the places given by: (Line):(Column).
3:41 5:63 6:92 7:113 9:164 10:191
NOTE: Variable tmp is uninitialized.
NOTE: There were 40 observations read from the data set
WORK.CHI2.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MPRINT(PROC_CODE):
****************************************************************
***********;
MPRINT(PROC_CODE): proc gslide;
SYMBOLGEN: Macro variable I resolves to 2
SYMBOLGEN: Macro variable TITLE resolves to All hospital
documents were available in the language I prefer
to read
MPRINT(PROC_CODE): title1 "Q2 All hospital documents were
available in the language I prefer to read" lspace=.5in
f="bold";
MPRINT(PROC_CODE): run;
WARNING: TITLE1 is too long. Height has been reduced to 69.13
pct of specified or default size.
WARNING: TITLE1 is too long. Height has been reduced to 70.97
pct of specified or default size.
NOTE: 2683 bytes written to
C:\Users\bt24\AppData\Local\Temp\1\SAS Temporary
Files\_TD4600_MW25F6B917-VMW_\gslide5.png.
MPRINT(PROC_CODE): quit;
NOTE: PROCEDURE GSLIDE used (Total process time):
real time 0.26 seconds
cpu time 0.20 seconds
MPRINT(PROC_CODE): *Bar chart #1;
NOTE: No units specified for the HORIGIN option. INCHES will
be used.
NOTE: No units specified for the VORIGIN option. INCHES will
be used.
NOTE: No units specified for the HSIZE option. INCHES will be
used.
NOTE: No units specified for the VSIZE option. INCHES will be
used.
MPRINT(PROC_CODE): goptions horigin=0 vorigin=6.75 hsize=3
vsize=3 htext=7pt htitle=9pt ;
MPRINT(PROC_CODE): axis1 label=(a=90 f="Albany AMT"
"Frequency") order=(0 to 220 by 40) minor=none;
MPRINT(PROC_CODE): axis2 label=none value=none;
MPRINT(PROC_CODE): axis3 label=none ;
MPRINT(PROC_CODE): legend1 label=("Response" h=2 pt
position=left j=c) position=(top inside left) mode=share;
MPRINT(PROC_CODE): pattern1 v=solid color=CX93BFBF;
MPRINT(PROC_CODE): pattern2 v=solid color=CX4791ED;
MPRINT(PROC_CODE): proc gchart
data=pd.griffin_collapsed_values;
SYMBOLGEN: Macro variable VAR resolves to doc_language
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): vbar doc_language/DISCRETE OUTSIDE=PERCENT
G100 GROUP=gender SUBGROUP=doc_language RAXIS=axis1 maxis=axis2
gaxis=axis3 legend=legend1 space=0 width=6 coutline=white;
SYMBOLGEN: Macro variable VAR resolves to doc_language
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): where doc_language not =. and doc_language
ne 99 and gender in (1,2);
SYMBOLGEN: Macro variable VAR resolves to doc_language
MPRINT(PROC_CODE): format gender genderf. doc_language yesno.;
MPRINT(PROC_CODE): title1 "Gender" ;
WARNING: Apparent symbolic reference CHIA not resolved.
SYMBOLGEN: Macro variable I resolves to 2
SYMBOLGEN: Macro variable CHIA2 resolves to Chi-Square Results
CHISQ(1)=0 p0.962
MPRINT(PROC_CODE): footnote1 j=c h=.75 f=Albany "Chi-Square
Results CHISQ(1)=0 p0.962";
MPRINT(PROC_CODE): run;
WARNING: The VBAR/VBAR3D chart for doc_language could not be
labeled because the labels are wider than the bars.
WARNING: There is not enough room for even one legend entry and
the label.
WARNING: The legend has been suppressed.
NOTE: Foreground color WHITE same as background. Part of your
graph might not be visible.
NOTE: 5009 bytes written to
C:\Users\bt24\AppData\Local\Temp\1\SAS Temporary
Files\_TD4600_MW25F6B917-VMW_\gchart15.png.
MPRINT(PROC_CODE): quit;
NOTE: There were 252 observations read from the data set
PD.GRIFFIN_COLLAPSED_VALUES.
WHERE doc_language not in (., 99) and gender in (1, 2);
NOTE: PROCEDURE GCHART used (Total process time):
real time 0.40 seconds
cpu time 0.29 seconds
MPRINT(PROC_CODE): title;
MPRINT(PROC_CODE): footnote;
479 ods pdf close;
NOTE: ODS PDF printed 1 page to \\vmware-host\Shared
Folders\Documents\My Documents\PreDict\Hospital
Reports\macro_a.pdf.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: