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-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
  • 700 views
  • 3 likes
  • 3 in conversation