SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
unwashedhelimix
Obsidian | Level 7

I have a csv data set that looks something like this:

states_csv.png

Now, I am looking to produce a PDF report that has all of the state info in the data set on one page like this:

states_report.png

The code I have to attempt this is the following:

proc import datafile = "path to csv file"
	out=StateDataSet
	dbms=csv
	replace;
run;

ods pdf file = "path to store pdf file";
proc print data = StateDataSet NOOBS label;
	format Area Comma7.0 Population Comma10.0;
	title  ;
	label State_Name = 'State Name';
	label State_Abbrev = 'State Abbrev.';
	label Postal_Abbrev = 'Postal Abbrev.';
	label Area = 'Area (Sq Mi)';
run;
ods pdf close;

However, the PDF produced stretches 2 pages, and it is in a table format. How can I format it, so that it is all in one page and it doesn't come out in the table format to replicate the example? 

3 REPLIES 3
Ksharp
Super User

You need customize your page size by "options papersize=(.....)".

 

proc freq data=sashelp.zipcode;
table STATENAME/out=StateDataSet;
run;


options nodate nonumber  papersize=(21cm 38cm) ;
ods pdf file = "c:\temp\temp.pdf" style=journal ;
proc print data = StateDataSet NOOBS label  ;
	title  ;
	label STATENAME = 'State Name';
run;
ods pdf close;
unwashedhelimix
Obsidian | Level 7

What is the proc freq for? I tried out the papersize options and the style, but the report wasn't quite in a format like below:

states_report.png

Ksharp
Super User
I wrote a PROC FREQ is just to make a sample data since you did not post a data.
You can delete PROC FREQ and use your original dataset to PROC PRINT.

" but the report wasn't quite in a format like "
What do you mean by that ? you can format your report as your wish/code :

options nodate nonumber papersize=(21cm 38cm) ;
ods pdf file = "c:\temp\temp.pdf" style=journal ;
proc print data = StateDataSet NOOBS label ;
format Area Comma7.0 Population Comma10.0;
title ;
label State_Name = 'State Name';
label State_Abbrev = 'State Abbrev.';
label Postal_Abbrev = 'Postal Abbrev.';
label Area = 'Area (Sq Mi)';
run;
ods pdf close;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 435 views
  • 0 likes
  • 2 in conversation