The SAS Output Delivery System and reporting techniques

how to include variables from different datasets in proc report

Reply
Regular Contributor
Posts: 166

how to include variables from different datasets in proc report

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

 

Super User
Posts: 24,026

Re: how to include variables from different datasets in proc report

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

 


 

Regular Contributor
Posts: 166

Re: how to include variables from different datasets in proc report

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 ??
Super User
Posts: 24,026

Re: how to include variables from different datasets in proc report

 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.

SAS Super FREQ
Posts: 9,434

Re: how to include variables from different datasets in proc report

[ Edited ]

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;
Ask a Question
Discussion stats
  • 4 replies
  • 151 views
  • 2 likes
  • 3 in conversation