BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
I have 15 sas scripts on unix box and i need to create a report showing the name of the sas script,all the input files and all the output files.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
When you say you have SAS "scripts" -- do you mean that you have Perl scripts or PHP scripts or Basic scripts that invoke SAS programs or do you mean that you have 15 .SAS programs????

If you are talking about SAS programs -- they are just ASCII text files. You could pipe a directory list to a file and then read that file of program names with a SAS program and/or a SAS macro program. If you were looking to read your text (.SAS) file, then you would search every program for references to DATA or SET or MERGE or INFILE. When you say you need to know the names of the output files, do you mean the datasets that are output by the programs or do you mean the ODS output???

There have been some user group papers written that talk about parsing SAS programs with another program.
http://www2.sas.com/proceedings/sugi31/150-31.pdf
http://www.codecraftersinc.com/ (look for the paper, entitled Meta Data + Files = Automated Status Reports)

You could also look at the SAS Code Analyzer (SCAPROC):
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003199745.htm
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003199751.htm
http://www.youtube.com/watch?v=vVoU5R1fNmk

cynthia
ptimusk
Obsidian | Level 7

I read SAS programs as 1000 character text variables. I then can, as Cynthia suggests, use various search methods like a WHERE statement to find DATA STEPS and extract only those lines or mark the line number in the program to know the beginning and end of the DATA STEP.  Or I can do a character search of that first keyword in a DATASTEP like DATA nameofdatset; to extract "nameofdataset.". I can find what the line number is for the beginning of that DATA STEP. I generally create an (_n_) based variable to define the line numbers to match the text variable containing the SAS program where one line of code is one observation.

Doc_Duke
Rhodochrosite | Level 12
For full generality, you could write a unix script to get the names of the SAS scripts from the Unix box and then feed that to a macro to parse the script results and find the files.

With just 15 scripts, you could do it manually much faster than writing the code de novo.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1289 views
  • 6 likes
  • 4 in conversation