Array validation using multiple if do loops

Reply
N/A
Posts: 1

Array validation using multiple if do loops

Hi, I am doing a conversion project from cobol to sas. Requirement is I need to do a lookup between a flat file and vsam file and pick only matched records using MRN.

Once MRN found, need to check if provider code in flat file match with mdno in vsam file which occurs 6 times.

Flat file:

Infile data1:

@01 MRN 12

@13 providercd 7.;

run;

Vsam file:

Infile data2 vsam;

@01 MRN 12

@13 providercd(1-6) 7.

@21 providerckdate 8.

@29 providedept 4.

*All 3 fields otherthan mrn occurs 6 times.

run;

I do vsam lookup here...

My logic should be able to do the following;

1.whenever providercd ne providercd(i) and providerdate < 62 days from today's date then output to errorout and goto next record. else if > 62 days goto next occurs

2.whenever providercd eq providercd(i) and providerdate < 366 days from today's date then output to errorout and goto next record else if > 366 days goto next occurs

If hit last occurs, write to goodfile.


I am not able to get this logic correct, because if it it value < than 62, its giving errorcd but not coming out of the loop.

Do i=1 to 6

If providercd ne providercd(i) then

if providerdate is < 62 days from today's date then

do;

errorcd=15;

output errorout;

end;

If providercd ne providercd(i) then

if providerdate is > 62 days from today's date then

do;

goto next occurs and when last occurs i=6 and if providerdate is > 62 days then

output goodfile;

end;

else If providercd equal providercd(i) then

if providerdate is < 366 days from today's date then

do;

errorcd=15;

output errorout;

end;

If providercd eq providercd(i) then

if providerdate is > 366 days from today's date then

do;

goto next occurs and when last occurs i=6 and if providerdate is > 366 days then

output goodfile;

end;

*******************************************

Please help me to get through this. I would like to know how to get out of a if loop and also ELSE condition is not working within a DO loop.

Also ow to move the last occurs value directly into goodfile.

Is there any way to display the values inside a sas step, for debugging.

Thanks in advance. Help much appreciated.

Super User
Posts: 19,157

Re: Array validation using multiple if do loops

I think a SQL merge may be better. Can you post some sample input data and output data? I realize your data is likely confidential so fake data that mimics your issue is fine.

Super User
Posts: 11,134

Re: Array validation using multiple if do loops

Are you reading the dates as SAS date values? That will greatly help for things like the intervals needed.

Ask a Question
Discussion stats
  • 2 replies
  • 190 views
  • 0 likes
  • 3 in conversation