BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Shanthi123
Fluorite | Level 6

Hello all,

 

can someone help me to create a loop logic .

my requirement: i want to search a list of table names in list of sas programs in a file. 

i have 400 table names and i have 4000 sas programs.

 

here is the code for for searching one single table in all the sas programs.

 

%LET NAME = "MRC_ORDER_SCHEDULE_PK";															
															
*************************************************************************************************************************************;															
FILENAME INP "/sasdata/mpn_sas/programs/prd/oracle/tdmh2k/*.sas";															
															
DATA TDMH2K;															
     ;															
LENGTH _filepath FILEPATH1 $550;															
INFILE INP FILENAME = _filepath LRECL=80 PAD END = DONE ;															
DO WHILE(NOT DONE);															
     INPUT REC $CHAR80.;															
     filepath1 = STRIP(_filepath);															
    RECNO+1;															
     IF INDEX(UPCASE(REC),&NAME) THEN OUTPUT;															
END;															
RUN;															

 

 

and here is the below code what i tried to do:

 

FILENAME INP "/sasdata/mpn_sas/programs/prd/oracle/tdmh2k/*.sas";


%macro test(NAME);
DATA TDMH2K_TEMP;
     ;
LENGTH _filepath FILEPATH1 $550;
INFILE INP FILENAME = _filepath LRECL=80 PAD END = DONE ;
DO WHILE(NOT DONE);
     INPUT REC $CHAR80.;
     filepath1 = STRIP(_filepath);
    RECNO+1;
     IF INDEX(UPCASE(REC),&NAME) THEN OUTPUT;

END;
RUN;
PROC APPEND BASE=TDMH2K DATA=TDMH2K_TEMP FORCE;
RUN;
%mend;
DATA _NULL_;
SET TEST ;
DO i=1 TO 5;
IF s_no=i then do;
CALL SYMPUTX('NAME',trim(table_name));
end;
end;
%TEST(&NAME);
run;



 

 

Can someone help .

 

here is the attached  output am getting. but i need the output with records. for one single table am able to get the output but when i try using loop .0 records.

 

1 ACCEPTED SOLUTION

Accepted Solutions
reprui
SAS Employee

Hello @Shanthi123 !

 

I wrote this code for analyzing my crypto mining logs and it could be modified to do what you are asking with some changes... 🙂

ClaymoreCryptoLogAnalysis.sas


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

View solution in original post

2 REPLIES 2
reprui
SAS Employee

Hello @Shanthi123 !

 

I wrote this code for analyzing my crypto mining logs and it could be modified to do what you are asking with some changes... 🙂

ClaymoreCryptoLogAnalysis.sas


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

Shanthi123
Fluorite | Level 6
Thanks for sharing.
Solution :
I got the logic by using call execute (%nrstr(%test("|| strip(name)||").
It worked.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 2929 views
  • 0 likes
  • 2 in conversation