BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
In a big list of sas programs, i would like to find out all the input and output dataset.. what is an easy way to do it?

I am thinking search by key words eg

Input dataset:
Use ’set’

Output dataset:
Use ’data’, ’output’, ’create table’

Have I missed out any??

Any other easier ways?
7 REPLIES 7
Patrick
Opal | Level 21

Please post your questions only once. 

 

Not exhaustive list of possible keywords:

 

For input:

from, join (for sql)

set, merge, modify

dataset: (when loading a data into hash)

 

For output:

create table

create view

out (for Procs)

data

 

And then you have also cases like below where SAS replaces the table without an out= or similar keyword:
proc sort data=mytable; by some_var; run;

 

And then there is also SQL UPDATE, INSERT and DELETE. 

 

...and last but not least: Formats and Informats.

ballardw
Super User

And data set UPDATE

 

ODS OUTPUT.

Some procedures like Proc Compare can create more than one output data set such as with the OUTSTATS= and uses Base= and Compare= as input data.

Proc Append with Base= and Data= input sets.

 

How about Proc Datasets and renaming data sets? Does that count?

 

Many procedures use more than one input data set. Proc Gmap for example has Data, Map and annotate as proc options and will accept additional Annotate data sets for each plot option.

 

Graphics procedures also have the annotate and may have helper data sets in SGplot for DATTRMAP and Rattermap data sets.

 

Survey procedures often have additional data set to deal with Sample information with names like Rate(R), Total, N, Sampsize, Samprate, Certsize, Maxsize and a bunch of others that may be data sets or values/value lists.

 

 

AllanBowe
Barite | Level 11

For the future you might want to consider the use of SASjs for documenting your SAS jobs.


If your developers follow the approach, you can generate Data Lineage diagrams (inputs/outputs) directly from the program headers.

 

Here are the docs:  https://cli.sasjs.io/doc/

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Reeza
Super User
If you can run the programs, PROC SCAPROC will provide this information in the log.
If you have macros in the code the input/output could be dynamic.
totoleheros
SAS Employee

As Reeza says, proc scaproc is the tool you need.

Run this code and look at your sas log : a lot of information is written there

Doc : https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0pbvhhaw4f7f7n1ukrvacsgulx1.htm 

 

/* start gathering data - add timestamp  + variables-related information */
options msglevel=I;
proc scaproc; 
   record '!temp/record.txt' attr OPENTIMES; 
run;

data a(keep=i index=(i)) b(keep=i j k) ; 
   do i = 1 to 1e7; 
      j = round(i,1e6); 
      k=sin(i);
      if mod(i,2)=0 then output a;
      else output b;
   end; 
run;

ods output  Univariate.j.BasicMeasures=BasicMeasures;
proc univariate data=b;
var j;
run;
ods output close;

proc summary data=b;
class j;
var k;
output out=summary sum=;
run;

proc sql;
create table c as select * from a where i < 100;

proc means data=a;
run;

/* write results to text file */ proc scaproc; write; run; /* examine what has been generated */ data _NULL_; infile '!temp/record.txt'; input; put _infile_; run;

 

Kurt_Bremser
Super User

Instead of scanning programs, scan logs. The NOTEs detailing datasets read and datasets written are quite standardized and much easier to parse than program statements.

HeatherNewton
Quartz | Level 8
In a big list of sas programs, i would like to find out sll the input snd output dataset.. what is an easy way to do it?

I am thinking search by key words eg

Input dataset:
Use ’set’

Output dataset:
Use ’data’, ’output’, ’create table’

Have I missed out any??

Any other easier ways?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 853 views
  • 2 likes
  • 7 in conversation