DATA Step, Macro, Functions and more

Check whether %include statement is exist in SAS code or not

Reply
Occasional Contributor
Posts: 7

Check whether %include statement is exist in SAS code or not

I have SAS code in which there is following line of code is included

% include "/sas/dev/compare.sas";

it is at location on server /sas/cpm/dev/code

So, at present what I am doing manually go to above path(through FTP) and open each .sas code(in a Folder, you can say there are 4 codes location at /sas/cpm/dev/code) and check whether %include "/sas/dev/compare.sas" line of code is present or not in.sas code

Can anyone help me without checking/open manually .sas code how to check whether %include "/sas/dev/compare.sas"; is exist or not

Can anyone , please help me how to write in sas, We can pass each code through macro right

Thanks

Super User
Posts: 23,235

Re: Check whether %include statement is exist in SAS code or not

[ Edited ]

.SAS files are text files, you can open with any text editor. So you’re basically searching a text file for a string, which you can do via grep in Unix or using FIND in SAS. You’ll find many examples if you use 'find specific text in a file' rather than your very specific question. 

 

https://gist.github.com/statgeek/26cf789d6da0ce941e447022fdccf0f4

 

 


@harry_87 wrote:

I have SAS code in which there is following line of code is included

% include "/sas/dev/compare.sas";

it is at location on server /sas/cpm/dev/code

So, at present what I am doing manually go to above path(through FTP) and open each .sas code(in a Folder, you can say there are 4 codes location at /sas/cpm/dev/code) and check whether %include "/sas/dev/compare.sas" line of code is present or not in.sas code

Can anyone help me without checking/open manually .sas code how to check whether %include "/sas/dev/compare.sas"; is exist or not

Can anyone , please help me how to write in sas, We can pass each code through macro right

Thanks


 

Occasional Contributor
Posts: 7

Re: Check whether %include statement is exist in SAS code or not

I will try this 

Thanks for reply

Super User
Posts: 9,868

Re: Check whether %include statement is exist in SAS code or not

Since you can log on with ftp, you can also get a commandline with PuTTY or similar.

Run the following:

find /sas/cpm/dev/code -name \*.sas -exec grep /sas/dev/compare.sas {} \; -print

and you'll get all occurrences, followed by the respective filename.

If you want to further process the result, redirect the output into a file.

 

The origins of UNIX are in text processing, and it is extremely powerful at that. Not making use of that power is silly at best.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 3 replies
  • 101 views
  • 3 likes
  • 3 in conversation