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

Hi,

 

I have a table with below data.

monthXYZ
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
monthXYZ

 

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

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
sivakoya
Obsidian | Level 7

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

 

View solution in original post

8 REPLIES 8
ballardw
Super User

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.

sivakoya
Obsidian | Level 7

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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...

sivakoya
Obsidian | Level 7

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

 

Cynthia_sas
SAS Super FREQ

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.

test_headers.png

 

  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

sivakoya
Obsidian | Level 7

@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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 8 replies
  • 1205 views
  • 0 likes
  • 4 in conversation