Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Not Working

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
0
0
CA
Hello

I am using SAS 9.1.

I have a health data database which has 20 procedures. I want to loop through them all and if it meets a certain criteria then indicate "Y" in the "surg" field.

The code I'm using is:

array proccde[20] $ proc1-proc20;
length surg $1.;
do i = 1 to 20;
if (substr(proccde,1,1)="1" and substr(proccde,4,2) in ('50','51','52','53','54','55','56'
'57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74'
'75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92',
'93','94','95','96','97','98','99') or
(substr(proccde,1,1)="5" and substr(proccde,4,2) in ('45','46','47','48','49','50','51','52','53','54','55','56'
'57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74'
'75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92',
'93','94','95','96','97','98','99'))) then surg="Y"; else surg="N";

The above works if only selecting on Proc1 but not with using the array. Please help - thanks.
 
Your code seems to overwrite the SURG var each time it loops through the array.
1)You can 'test' for SURG = 'Y' and not overwrite it.
2)You can export the results as you loop through the array and then you will have your list.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top