BookmarkSubscribeRSS Feed
harry_87
Calcite | Level 5

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

3 REPLIES 3
Reeza
Super User

.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


 

harry_87
Calcite | Level 5

I will try this 

Thanks for reply

Kurt_Bremser
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 883 views
  • 3 likes
  • 3 in conversation