BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

I have problem I have variables from different datasets that I want them to appear in the same table in proc report 

Please advise me what is the best way to do that?? 

 

4 REPLIES 4
Reeza
Super User

Combine them into a single data set first and then use PROC REPORT. As far as I know, there is no way to specify two input data sets to PROC REPORT.

 


@mona4u wrote:

I have problem I have variables from different datasets that I want them to appear in the same table in proc report 

Please advise me what is the best way to do that?? 

 


 

mona4u
Lapis Lazuli | Level 10
my problem is one of the data set has frequency of variable and the other one has the frequency of the same variable >30 days. I used if statement in the second data set and that's why I put them in two proc report steps. Please advise me how to report a set and a subset in the same step ??
Reeza
Super User

 Please advise me how to report a set and a subset in the same step ??

 

Can you provide an example of what you're referring to here? There's no code or data so even trying to guess what you're doing is difficult.

Cynthia_sas
SAS Super FREQ

Hi:
As @Reeza explained, PROC REPORT is designed to only operate on 1 dataset at a time. So you can only do 2 PROC REPORTs one after the other or, if you want the information from 2 datasets in one report, you will have to combine the 2 datasets together, using either SQL or MERGE and then do your report. Here's an example with some fake data. Since you did not provide any data or any code, it is hard to guess what your data or your code looks like or what kind of report you want. However, just making a very, very simple example, with 2 datasets, here's one approach.

cynthia

 

data onefile;
  infile datalines;
  input name $ amount;
return;
datalines;
alan 100
barb 200
carl 300
diana 400
eddie 500
;
run;

data after30;
  infile datalines;
  input name $ amount30;
return;
datalines;
alan 150
barb 275
carl 343
diana 454
eddie 577
;
run;
 
data final;
  merge onefile(in=inone) after30(in=in30);
  by name;
  if inone and in30 then output;
run;
 
proc report data=final;
  column name amount amount30;
  define name / order;
  define amount / "Original Amount";
  define amount30 / "Amount after 30";
  rbreak after / summarize;
run;

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
  • 4 replies
  • 869 views
  • 2 likes
  • 3 in conversation