The SAS Output Delivery System and reporting techniques

Columns= for ODS PDF & ODS RTF

Reply
Occasional Contributor
Posts: 14

Columns= for ODS PDF & ODS RTF

My goal is to be able to switch from 2 column to 1 column to 2 columns, etc as needed throughout my PDF & RTF (at minimum the PDF); preferably without page breaks. However, I would give up page breaks to get control of the columns.

I did try this with and without page breaks (startpage=now) and it did not work either.

I start with the code below.
Proc this... represents where proc statements would go.

Thank you in advance for your help,
Karen


ODS Escapechar = '^';
ODS pdf file = 'S:\Science and Research\Survey Research\AAD Dept\Education\ABD Prep Course Follow-up Survey\stats\Item frequencies.pdf'
Style=theme uniform startpage = no ;
footnote 'Page ^{thispage} of ^{lastpage}';
ODS noptitle;
ods proclabel '2010 Exam Prep Course Post-test Survey';

ODS RTF FILE= 'S:\Science and Research\Survey Research\AAD Dept\Education\ABD Prep Course Follow-up Survey\stats\Item frequencies.rtf'
startpage=no keepn contents=yes Style=theme sasdate;
footnote 'Page ^{thispage} of ^{lastpage}';
ODS noptitle;
ods proclabel '2010 Exam Prep Course Post-test Survey';
ods pdf columns=2;
ods rtf columns=2;


PROC.....

ods pdf columns=1;
ods rtf columns=1;
PROC.....
ods pdf columns=2;
ods rtf columns=2;

PROC.....
PROC.....

ods pdf columns=1;
ods rtf columns=1;
ods pdf columns=2;
ods rtf columns=2;

PROC.....
PROC.....


ODS _all_ CLOSE;

ODS LISTING;
SAS Super FREQ
Posts: 8,869

Re: Columns= for ODS PDF & ODS RTF

Hi:
Specifically, how would you want to change this output???? When I run these programs and switch columns= in between steps, I get the output I expect. If you want more control over the layout of your columns or regions, you might want to investigate ODS LAYOUT.

This paper talks about COLUMNS= and ODS LAYOUT.
http://www.wuss.org/proceedings09/09WUSSProceedings/papers/dpr/DPR-OConnor.pdf

cynthia
[pre]
ODS Escapechar = '^';

ods listing close;

ODS pdf file = 'c:\temp\Item_frequencies.pdf'
Style=theme uniform startpage = no ;
footnote 'Page ^{thispage} of ^{lastpage}';
ODS noptitle;
ods proclabel '2010 Exam Prep Course Post-test Survey';

ODS RTF FILE= 'c:\temp\Item_frequencies.rtf'
startpage=no keepn contents=yes Style=theme sasdate;
footnote 'Page ^{thispage} of ^{lastpage}';
ODS noptitle;
ods proclabel '2010 Exam Prep Course Post-test Survey';
ods pdf columns=2;
ods rtf columns=2;

proc print data=sashelp.shoes(obs=50);
var region product sales;
run;

ods pdf columns=1;
ods rtf columns=1;

proc means data=sashelp.shoes min mean max;
class product;
var inventory;
run;

ods pdf columns=2;
ods rtf columns=2;

proc print data=sashelp.shoes(obs=50);
var region product returns;
run;

ODS _all_ CLOSE;
[/pre]
Occasional Contributor
Posts: 14

Re: Columns= for ODS PDF & ODS RTF

Posted in reply to Cynthia_sas
OOHH I like the article.

However. when I use it as specified my General 'table' for question 5 still comes out as two columns (1/2 the table, then just below the other half of the table) but on it's own page in the PDF. PDF files are not as flexible as the RTF files.

Table looks fine in RTF but there are extra page breaks in the RTF. It may be that for RTF, it would be easier to manually adjust the columns.

We are still working with SAS 9.1.3 SP4. Would that be part of the problem?

Here is a stripped down version of my code that still provides the same output.

ODS Escapechar = '^';
ODS pdf file = 'c:\Item frequencies.pdf'
Style=theme uniform startpage = no ;
footnote 'Page ^{thispage} of ^{lastpage} ';
ODS noptitle;
ods proclabel 'Exam Prep Post-test Survey';

ODS RTF FILE= 'c:\frequencies.rtf'
startpage=no keepn contents=yes Style=theme sasdate;
footnote 'Page ^{thispage} of ^{lastpage}';
ODS noptitle;
ods proclabel 'Exam Prep Post-test Survey';


ods pdf columns=2 ;
ods rtf columns=2 ;


data dsv1test;
set ds;
varn = '2-day Nov 2010'; resp = Q1_1; output;
varn = '1-day Mar 2010'; resp = Q1_2; output;
varn = '1-day Aug 2010'; resp = Q1_3; output;
varn = 'None of these'; resp = Q1_4; output;
keep casenumber nsize varn resp Q1_nr;
run;
ods proclabel 'Exam Course Post-test Survey';
/*this uses data from dsv1test*/
Proc report data = dsv1test nowd;
Columns varn resp persel;
where resp=1;
Define varn / display group format= $25.;
Define resp /sum;
Define persel / computed format=pctfmt12.3 '%';
label
varn = 'Course Attended'
resp = 'n';
compute persel;
persel= (_C2_ / &num)*100;
endcomp;
run;

proc freq data = ds ;
label q1_nr = 'Respondents not selecting any choices in Question 1: ';
format q1_nr ns.;
table q1_nr/missing nocum;
Run;

PROC surveyFREQ data = ds missing order = formatted nosummary;
ODS noptitle;
Label &labelit;
Format &formatit;
/*order is important for FORMAT- the last format is the one used by the proc*/
OPTIONS FORMCHAR="|----|+|---+=|-/\<>*";
tables Q1_1 Q1_2 Q1_3 Q1_4 /nostd ;
Run;

ods proclabel 'Attend Other Course';

PROC surveyFREQ data = ds missing order = formatted nosummary;
ODS noptitle;
Label &labelit;
Format &formatit;
/*order is important for FORMAT- the last format is the one used by the proc*/
OPTIONS FORMCHAR="|----|+|---+=|-/\<>*";
tables Q2/nostd ;
Run;

data dsv3test;
set ds;
varn = 'choice1 '; resp = Q3_1; output;
varn = 'Choice2'; resp = Q3_2; output;
varn = 'choice3'; resp = Q3_3; output;
varn = 'No additional materials'; resp = Q3_4; output;
varn = 'Other'; resp = Q3_5; output;
keep casenumber varn resp Q3_nr nsize;
run;

ods proclabel 'Additional Prep Resources';

/*this uses data from dsv1test*/
Proc report data = dsv3test nowd;
Columns varn resp persel;
Label
varn = 'Other materials used'
Resp = 'n';
where resp=1;
Define varn / display group format= $25.;
Define resp /sum;
Define persel / computed format=pctfmt12.3 '%';
compute persel;
persel= (_C2_ / &num)*100;
endcomp;
run;

proc freq data = ds;
label q3_nr = 'Respondents not selecting any choices in Question 3: ';
format q3_nr ns.;
table q3_nr/missing nocum;
Run;


PROC surveyFREQ data = ds missing order = formatted nosummary;
ODS noptitle;

/*order is important for FORMAT- the last format is the one used by the proc*/
OPTIONS FORMCHAR="|----|+|---+=|-/\<>*";
tables Q3_1 Q3_2 Q3_3 Q3_4 Q3_5/nostd;
Run;
data dsv5q;
set ds;
retain rlabel ' ';
if q5a = .N then q5a = 6; else;
if q5b = .N then q5b = 6; else;
if q5c = .N then q5c = 6; else;
if q5d = .N then q5d = 6; else;
if q5a = . then q5a = 7; else;
if q5b = . then q5b = 7; else;
if q5c = . then q5c = 7; else;
if q5d = . then q5d = 7; else;
length varn rlable $20;
varn = 'a. thing 1'; resp = Q5a;
if resp = 1 then rlabel = 'a)Very high value';
if resp = 2 then rlabel = 'b)High value';
if resp = 3 then rlabel = 'c)Moderate value';
if resp = 4 then rlabel = 'd)Low value';
if resp = 5 then rlabel = 'e)Very low value';
if resp = 6 then rlabel = 'f)Did not attend';
if resp = 7 then rlabel = 'g)No response';
output;
varn = 'b. thing 2'; resp = Q5b ;
if resp = 1 then rlabel = 'a)Very high value';
if resp = 2 then rlabel = 'b)High value';
if resp = 3 then rlabel = 'c)Moderate value';
if resp = 4 then rlabel = 'd)Low value';
if resp = 5 then rlabel = 'e)Very low value';
if resp = 6 then rlabel = 'f)Did not attend';
if resp = 7 then rlabel = 'g)No response';
output;
varn = 'thing 3'; resp = Q5c ;
if resp = 1 then rlabel = 'a)Very high value';
if resp = 2 then rlabel = 'b)High value';
if resp = 3 then rlabel = 'c)Moderate value';
if resp = 4 then rlabel = 'd)Low value';
if resp = 5 then rlabel = 'e)Very low value';
if resp = 6 then rlabel = 'f)Did not attend';
if resp = 7 then rlabel = 'g)No response';
output;
varn = 'thing 4'; resp = Q5d ;
if resp = 1 then rlabel = 'a)Very high value';
if resp = 2 then rlabel = 'b)High value';
if resp = 3 then rlabel = 'c)Moderate value';
if resp = 4 then rlabel = 'd)Low value';
if resp = 5 then rlabel = 'e)Very low value';
if resp = 6 then rlabel = 'f)Did not attend';
if resp = 7 then rlabel = 'g)No response';
output;
keep varn resp casenumber rlabel nsize;
run;

ods pdf startpage = now;
ods pdf columns=1;
ods rtf columns=1 startpage=no ;

ods proclabel 'Exam Course: General Content Area';

proc report data=dsv5q nowd;
Columns varn rlabel, (resp persel) dummy;
Define varn/ display group 'General Content Area';
Define rlabel/ display across 'Scale';
define persel/ computed format=pctfmt12.3 '%';
define resp/ n 'n';
define dummy/ noprint;
compute dummy;
_C3_ = _C2_ /&num;
_C5_ = _C4_ /&num;
_C7_ = _C6_ /&num;
_C9_ = _C8_ /&num;
_C11_ = _C10_ /&num;
_C13_ = _C12_ /&num;
endcomp;
run;

ods pdf startpage = now;
ods pdf columns=2;
ods rtf columns=2 startpage=no ;

proc freq data = ds ;
label q5_nr = 'Respondents not selecting any choices in Question 5: ';
format q5_nr nr.;
table q5_nr/missing nocum;
Run;

PROC surveyFREQ data = ds missing order = formatted nosummary;
ODS noptitle;
/*order is important for FORMAT- the last format is the one used by the proc*/
OPTIONS FORMCHAR="|----|+|---+=|-/\<>*";
tables Q5a Q5b Q5c Q5d /nostd ;
Run;



ODS _all_ CLOSE;

ODS LISTING;
SAS Super FREQ
Posts: 8,869

Re: Columns= for ODS PDF & ODS RTF

Hi:
In short, yes. ODS LAYOUT (for sure) was enhanced between 9.1.3 and 9.2; although COLUMNS= ... I'm not so sure about.

I do not have the dataset WORK.DS to run the code in 9.2 -- so it's impossible to say how this would look in 9.2. But, if your issue is with 9.1.3, you might want to open a track with Tech Support on this question. They can look at the actual data and your code and test it on SAS 9.1.3 and tell you whether what you want to do is possible.

cynthia
Occasional Contributor
Posts: 14

Re: Columns= for ODS PDF & ODS RTF

Posted in reply to Cynthia_sas
Hi Cynthia,

Thank you! We are planning an update at our next SAS renewal.
This gives me something to look forward to in the next upgrade.

Karen
SAS Super FREQ
Posts: 8,869

Re: Columns= for ODS PDF & ODS RTF

Hi,
Here's the thing... I still can't quite visualize what you are attempting, but I think you will need ODS Layout. You still might want to work with Tech Support to see whether what you want is achievable.

Cynthia
Ask a Question
Discussion stats
  • 5 replies
  • 1104 views
  • 0 likes
  • 2 in conversation