BookmarkSubscribeRSS Feed
sharath_rk
Calcite | Level 5


The below loop fails only for wk 51 & wk 52 data for FY14 Q4. The loop works fine for all other time periods. Please advise what could be the reason

SELECT (REGION);
   WHEN ('Americas')
    DO;
     IF IP_DATE = . OR DLVR_STRT_DTS = .   THEN DO;
         SDS_EXP_IP = 'N/A';
      SDS_GRD_IP = 'N/A';
      SDS_ALL_IP = 'N/A';
     END;
     ELSE DO;
      IF DATEPART(IP_DATE) = DATEPART(DLVR_STRT_DTS) THEN SDS_ALL_IP = 'MADE';
      ELSE               SDS_ALL_IP = 'MISS';
      IF SHIP_CD IN ('2','7') THEN DO;
       SDS_GRD_IP = 'N/A';
       IF DATEPART(IP_DATE) = DATEPART(DLVR_STRT_DTS) AND
                            TIMEPART(DLVR_STRT_DTS) LE "19:00"T             THEN SDS_EXP_IP = 'MADE';
       ELSE              SDS_EXP_IP = 'MISS';
      END;
      ELSE DO;
       SDS_EXP_IP = 'N/A';
       SDS_GRD_IP = SDS_ALL_IP;
      END;
     END;
    END;
   WHEN ('EMEA','APJ')
    DO;
     SDS_EXP_IP = 'N/A';
     SDS_GRD_IP = 'N/A';
     IF DATEPART(IP_DATE) = DATEPART(DLVR_STRT_DTS) THEN  SDS_ALL_IP = 'MADE';
     ELSE              SDS_ALL_IP = 'MISS';
    END;
  END;
END;

END;

9 REPLIES 9
art297
Opal | Level 21

Your error is probably coming from somewhere else in your data step.

sharath_rk
Calcite | Level 5

as per the line number in the error message it states that When clause is not satisfied even though there's data for EMEA & APJ

PGStats
Opal | Level 21

I think the message warns you about the fact that you've got some data where REGION is not "Americas" or "AMEA" or "APJ". Add an OTHERWISE clause to your SELECT block to detect those.

PG

PG
Reeza
Super User

SAS will tell you that one

ERROR: Unsatisfied WHEN clause and no OTHERWISE clause at line 552 column 1.

And you can use a list in your When Clause.

art297
Opal | Level 21

Fareeza: I deleted my post about not being able to use a list.  I tested it, after posting, and then went back and deleted my post.

sharath_rk
Calcite | Level 5

The issue has been resolved by using the otherwise clause. IT appears the format for region name had changed for specific weeks causing the loop to fail.

Thank you so much for each one of you for the guidance.


Reeza
Super User

I'd check if the DO/END matched. The way you have the code right now (indent!), I'm not about to figure it out.

The full code/error/log is also useful if you're trying to debug something.

sharath_rk
Calcite | Level 5

everything is matched for other time period data extractions. When i try to extract data for a specific period then i am getting the error. If i do the extraction for a week prior it works and the same goes for a week later from the specific period. Please advise.

Reeza
Super User

Post the full code/error/log.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 1666 views
  • 6 likes
  • 4 in conversation