BookmarkSubscribeRSS Feed
m_u_r_a_l_i
Calcite | Level 5
Hi,

I create a report using the PROC REPORT facility, and this is how my code looks :-

PROC REPORT DATA=MERGED NOCENTER NOWD HEADLINE HEADSKIP MISSING;
COLUMN SDC SDCDESC N SHEETCT;
DEFINE SDC / GROUP FORMAT=£4. 'SDC';
DEFINE SDCDESC / GROUP FORMAT=£40. 'PRODUCT DESCRIPTION';
DEFINE SHEETCT / ANALYSIS SUM FORMAT=7. 'SHEET COUNT';

COMPUTE AFTER;
LINE "TOTAL MPKT COUNT : "
N 10.;
LINE "TOTAL SHEET COUNT: "
SHEETCT.SUM 10.;
ENDCOMP;

I execute this in the mainframe, using a batch job written in JCL. And when I complete running this job, I am able to see the report in SASLIST (similar to sysout). Now I want the o/p of PROC REPORT to be moved into a dataset.

Can someone please let me know how I can do that !

Thanks.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
PROC REPORT supports an OUT= option like this:
[pre]
PROC REPORT DATA=MERGED NOCENTER NOWD
HEADLINE HEADSKIP MISSING OUT=work.reptout;

PROC REPORT DATA=MERGED NOCENTER NOWD
HEADLINE HEADSKIP MISSING OUT=permlib.reptout;

[/pre]

Of course, options like HEADLINE/HEADSKIP have no effect the output dataset. In addition, output from LINE statements is not put into the dataset. You will also notice an extra variable is added to the output dataset. This variable is named _BREAK_ and if you have BREAK or RBREAK statements in your code, you will see output that looks like this:
[pre]
Obs Region Product Sales _BREAK_

1 Asia Boot $62,708
2 Asia Men's Casual $11,754
3 Asia Men's Dress $119,366
4 Asia Sandal $8,208
5 Asia Slipper $152,032
6 Asia Sport Shoe $2,092
7 Asia Women's Casual $25,837
8 Asia Women's Dress $78,234
9 Asia Total $460,231 Region
10 Canada Boot $385,613
11 Canada Men's Casual $441,903
12 Canada Men's Dress $920,101
13 Canada Sandal $14,798
14 Canada Slipper $952,751
15 Canada Sport Shoe $140,389
16 Canada Women's Casual $410,807
17 Canada Women's Dress $989,350
18 Canada Total $4,255,712 Region
19 Total $4,715,943 _RBREAK_


[/pre]

This output was created with the program shown below.
You cannot currently use the OUT= option with a PROC REPORT that uses a BY statement.

cynthia

[pre]
ods listing;
proc report data=sashelp.shoes nowd
out=work.reptout;
where region in ('Asia', 'Canada');
column region product sales;
define region / group;
define product /group;
define sales /sum;
break after region /summarize skip;
compute after region;
region = trim(region)||' Total';
endcomp;
rbreak after / summarize;
compute after;
region = 'Total';
endcomp;
run;

options nocenter nodate nonumber;
proc print data=work.reptout;
run;
[/pre]
m_u_r_a_l_i
Calcite | Level 5
Thanks a lot Cynthia ! I also found that there is a command called PRINTTO, which routes the SAS PROC output to a dataset !

This is how I coded it :-

PROC PRINTTO PRINT=SASOUT NEW;
RUN;

Many Thanks,
Murali.
deleted_user
Not applicable
Actually, PrintTo doesn't write to a data set, it writes textual content to a file.

"DATASET" implies a SAS construction of defined columns and populated rows, and this is what Cynthia's answer will give you.

Kind regards

David

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
  • 3 replies
  • 627 views
  • 0 likes
  • 3 in conversation