Hello!
I'm trying to generate a report to briefly show how a facility responded to a survey. I currently have my data in this format, where there are variables listing all questions that they provided that answer to.
data have;
input fac_name $ ans_yes $ ans_no $ ans_always $ ans_sometimes $ ans_never $;
datalines;
"Facility A" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
"Facility B" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
;
I would like to generate a PDF report with a page that basically looks like this for each facility:
Facility Name: fac_name
Answered "yes": ans_yes
Answered "no": ans_no
Answered "always": ans_always
Answered "sometimes": ans_sometimes
Answered "never": ans_never
Basically, on each line I would like a string of text (ex. 'Answered "yes"') followed by the value of the variable for that facility. I can only figure out how to provide output in a table format, is there a way to just print values of a variable to a PDF document like this?
Thank you!
Something that will look like that though technically is still a table.
data have;
infile cards dsd dlm=' ';
length fac_name $16;
array ans $24 yes no always sometimes never;
input (fac_name ans[*]) (:);
datalines;
"Facility A" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
"Facility B" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
;;;;
proc odstext data=have;
list;
item 'Facility Name: ' || fac_name;
item 'Answered "yes": ' ||yes ;
item 'Answered "no": ' ||no ;
item 'Answered "always": ' ||always;
item 'Answered "sometimes": ' ||sometimes;
item 'Answered "never": ' ||never ;
end;
;
run;
ods pdf file='answers.pdf';
data have;
file print;
infile cards dsd dlm=' ';
length fac_name $16;
array ans $24 yes no always sometimes never;
input (fac_name ans[*]) (:);
put 'Facility name: ' fac_name;
length Answered $16;
do i = 1 to dim(ans);
Answered = quote(vname(ans[i]));
put answered= +(-1) ': ' ans[i];
end;
put;
datalines;
"Facility A" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
"Facility B" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
;;;;
run;
ods pdf close;
If you are interested in making the Report a bit fancy, you might want to look into the
ODS Report Writing Interface Check the examples section
http://support.sas.com/rnd/base/ods/Tipsheet_RWI.pdf
Hope this helps,
Ahmed
Something that will look like that though technically is still a table.
data have;
infile cards dsd dlm=' ';
length fac_name $16;
array ans $24 yes no always sometimes never;
input (fac_name ans[*]) (:);
datalines;
"Facility A" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
"Facility B" "yes answers" "no answers" "always answers" "sometimes answers" "never answers"
;;;;
proc odstext data=have;
list;
item 'Facility Name: ' || fac_name;
item 'Answered "yes": ' ||yes ;
item 'Answered "no": ' ||no ;
item 'Answered "always": ' ||always;
item 'Answered "sometimes": ' ||sometimes;
item 'Answered "never": ' ||never ;
end;
;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.