Solved
Contributor
Posts: 30

ODS PDF_proc report column header getting sorted

Hi,

I have a table with below data.

 month X Y Z Jan2014 \$3,492.57 \$7,185.22 \$2,026.43 Feb2014 \$2,816.10 \$14,700.26 Mar2014 \$2,904.22 \$11,052.74 \$1,722.06 Apr2014 \$2,662.51 \$13,353.37 \$2,437.22 May2014 \$3,615.86 \$1,061.01 Jun2014 \$3,178.15 \$2,461.64

I am using this code to print data to PDf

ods pdf startpage=now;

ods pdf text="^S={just=C font_weight=bold font_size=15pt font_face=arial} Monthly Rates by Segment";

proc report data=rates_all_Segment_1;

columns

month

X

Y

Z

;

define month / order=data display;

define X / display;

define Y / display;

define Z / display;

run;

output:

 Jan2014 \$3,492.57 \$7,185.22 \$2,026.43 Feb2014 \$2,816.10 ######## Mar2014 \$2,904.22 ######## \$1,722.06 Apr2014 \$2,662.51 ######## \$2,437.22 May2014 \$3,615.86 \$1,061.01 Jun2014 \$3,178.15 \$2,461.64 month X Y Z

for some reason my header are getting sorted too. Need help on this.

Thanks

Accepted Solutions
Solution
‎01-24-2017 01:25 PM
Contributor
Posts: 30

Re: ODS PDF_proc report column header getting sorted

Hi @RW9 @ballardw thanks for the response.

data have;

input month_end date7. x y;

format month_end monyy5.;

datalines;

30sep16 1 100

31oct16 1 50

30nov16 1 25

30dec16 1 10

30sep16 2 100

31oct16 2 0

30sep16 3 0

;

run;

My dataset looks like this.

when I se proc report and output this to PDF, column names are sorting along with rows and getting printed at bottom.

Font sise I was using was 15pts and the report is going to next page.

I have tried rerunning the report with fontsize 10pts, now it works fine. Column names are printing at the top.

Thanks

All Replies
Super User
Posts: 13,563

Re: ODS PDF_proc report column header getting sorted

Provide some example input data and the desired output. Since you don't show any headers it's a bit difficult to see what you mean.

Contributor
Posts: 30

Re: ODS PDF_proc report column header getting sorted

input data:

Month  X   Y   Z

Jan14   1   1    1

Feb14   1   1   1

Mar14   1   1

Desired Output:

Month  X   Y   Z

Jan14   1   1    1

Feb14   1   1   1

Mar14   1   1   1

im getting this though

Jan14   1   1    1

Feb14   1   1   1

Mar14   1   1   1

Month  X   Y   Z

Thanks

Super User
Posts: 9,599

Re: ODS PDF_proc report column header getting sorted

Provide test data in the form of a datastep.  We cannot see what your working with.  It looks to me like your headers are rows, not column headers at all, maybe you imported a text file and read in the first row (header row) as well.  If you don't know how to make a datastep of your data follow this:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Solution
‎01-24-2017 01:25 PM
Contributor
Posts: 30

Re: ODS PDF_proc report column header getting sorted

Hi @RW9 @ballardw thanks for the response.

data have;

input month_end date7. x y;

format month_end monyy5.;

datalines;

30sep16 1 100

31oct16 1 50

30nov16 1 25

30dec16 1 10

30sep16 2 100

31oct16 2 0

30sep16 3 0

;

run;

My dataset looks like this.

when I se proc report and output this to PDF, column names are sorting along with rows and getting printed at bottom.

Font sise I was using was 15pts and the report is going to next page.

I have tried rerunning the report with fontsize 10pts, now it works fine. Column names are printing at the top.

Thanks

SAS Super FREQ
Posts: 9,370

Re: ODS PDF_proc report column header getting sorted

HI:

When I use your posted data and almost the same version of the posted program I do not observe the same results. See the PDF and HTML output in the screen shot below.

I am not sure how/why you are getting column headers at the bottom of the table except that the only time I've see that happen is when someone has all character variables and they accidentally read the first row in a comma separated file as data instead of using the FIRSTOBS=2 option.

But, you posted a program to make your data and I don't see what you are describing. You might want to look at the dataset with a PROC PRINT and see whether PROC PRINT displays the same type of row for the last row of data.

Perhaps someone else has other suggestions. I'm stumped.

cynthia

Contributor
Posts: 30

Re: ODS PDF_proc report column header getting sorted

@Cynthia_sas @ballardw thanks for your explanation. I have double checked my dataset and it is not all character variable set and I am not importing any file. For some reason I run the same code by decreasing the PDF font it perfects prints the data. If I increase the font variable names get sorted and gets printed at the end of the PDF page. Maybe I am doing someting wrong, I am not sure.  Right now my problem is solved. If I ever see that problem again I will take screenshots and post it here.

Super User
Posts: 9,599

Re: ODS PDF_proc report column header getting sorted

Hi,

I am sorry, this is not the correct answer.  From the data you presented the output is as @Cynthia_sas has given.  I don't see anyway to have dataset labels appearing in the data, unless they are data.  Also, chaning the font should not make any difference to the layout of the data.  The only time I have seen a zoom make any difference to an outpu is the lines are sometimes not rendered until zoomed in.  I was advise that you contact SAS support and get this resolved as it could be anything from a bad SAS setup through to your program, and the information provided here doesn't give the output you describe.

Super User
Posts: 13,563

Re: ODS PDF_proc report column header getting sorted

Post the results of :

Proc contents data=rates_all_Segment_1;

run;

If you find that all of your variables are character that's the likely culprit.

Or use the instructions at https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to create datastep code to duplicate the rates_all_segment_1 data set.

BTW your example data does not match the code provided with differently named date variable and missing the variable z.

☑ This topic is solved.