BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
megsredl
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

6 REPLIES 6
data_null__
Jade | Level 19

 

 

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;

Capture.PNG

AhmedAl_Attar
Rhodochrosite | Level 12

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

 

megsredl
Obsidian | Level 7
This is very helpful, thank you!
ballardw
Super User

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;
megsredl
Obsidian | Level 7
Thank you, PROC ODSTEXT is exactly what I was looking for!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 691 views
  • 3 likes
  • 4 in conversation