Given Data A; would like to have output shown below either in PDF/RTF file format. Any help?
data a;
input ID $ a b c d e f g h;
cards;
ABC 1 2 3 4 5 6 7 8
XYZ 4 3 2 1 8 7 6 5
;
run;
Output PDF/RTF :
ABC 1 2 3 4
(5) (6) (7) (8)
XYZ 4 3 2 1
(8) (7) (6) (5)
Hi:
What code have you tried?? PROC PRINT, PROC REPORT, PROC TABULATE? Other? It might be possible with data manipulation to create a report format that will work for you as you show, but that would probably involve at least a data step and then PROC REPORT.
It's useful to see your data, but would be also useful to know what you've already tried.
Cynthia
Thanks Cynthia for your response.
data a;
input ID $ a b c d e f g h;
cards;
ABC 1 2 3 4 5 6 7 8
XYZ 4 3 2 1 8 7 6 5
;
run;
data _null_;
set a;
x='(';
y=')';
xhy=cats(x,h,y);
xey=cats(x,e,y);
xfy=cats(x,f,y);
xgy=cats(x,g,y);
by id notsorted;
file print notitle;
if (first.id or last.id) then do;
Put @10 id @20 a @35 b @50 c @65 d /
@20 xey @35 xfy @50 xgy @65 xhy
;
end;
run;
Hi:
Using PUT statements will not work as you envision for PDF or RTF output. Basically when you start, you have 1 row per ID, but your report only has 4 columns going across. If you want "nice" PDF or RTF output, you'll have to move away from PUT statements and use the PUT function to get the parentheses on row 2 for each ID. Then, use PROC REPORT for reporting. I envisioned something more like this, where the DATA step does the restructure and then PROC REPORT just needs to display the records.
I show HTML output in my screen shot, but you can easily create RTF or PDF output by putting an ODS "sandwich" around the PROC REPORT step (and only the PROC REPORT step):
ods pdf file='c:\temp\final_report.pdf';
...insert REPORT code here;
ods pdf close;
or
ods rtf file='c:\temp\final_report.rtf';
...insert REPORT code here;
ods rtf close;
Here's my approach.
Hope this gives you an alternate idea for a solution.
Cynthia
Thanks Cynthia. Appreciated your efforts, time and elegant solution.
Your solutions is accepted.
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 25. 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.