Hello,
I am not famillar with _IORC_ at all and trying to understand the logic of a SAS developper absent for few months.
PROC DATASETS NOLIST LIBRARY= temp;
MODIFY histo_gc_auto_norisk;
/* INDEX DELETE _ALL_;*/
INDEX CREATE COMPKEY=(AGREEMENT_NBR DATEMISS DATECHEA) / UNIQUE NOMISS;
RUN;
DATA TEMP.Auto TEMP.A;
set TEMP.A;
RCLASS3=RCLASS2;
if RCLASS2 NE 'PERSAUTO' THEN OUTPUT;
ELSE DO;
SET temp.histo_gc_auto_norisk KEY=COMPKEY/UNIQUE;
IF _IORC_ THEN
DO;
OUTPUT;
END;
ELSE
DO;
RCLASS2 ='COMMAUTO';
RCLASS2P='COMMIRCA';
OUTPUT;
END;
END;
RUN;
The begining seems strange:
DATA TEMP.Auto TEMP.A;
set TEMP.A;
and based on the script everything goes in both datasets.
Does someone can help me with that?
The WARNING is a result of preceding ERRORs, usually caused by invalid data. You need to check those.
I think that a _IORC_ value of zero means success, but that's a guess. As described in the documentation I linked, use %SYSRC to see the real numeric value for SOK.
As you observe, the DATA step creates two identical datasets (none of the OUTPUT statements is tied to a specific dataset).
It uses a SET with KEY and checks the automatic variable _IORC_ for a non-zero value (= true) to do nothing, or set two variables in case of a zero value (= false). According to this, this usage is not completely future-proof.
I guess(!) that the variables need to be set if a match is found. Today, I would use a hash object for this.
so, if we make the hypothesis that records with none unique key get a _IORC_ value of zero because for the same agreement_nbr they have multiple datemiss and datechea, and in that case the two variables RCLASS2 AND RCLASS2P need to be remapped to new values.
and how to deal with warning ?
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
GCNA_BRANCH= DATECHEA=25-11-04 DATEMISS=24-11-04 DATANNUL=. ASSPREC=WA BASETAR=1 CIEDISTR= CODEFPQ=1 COURTIER=0024 DATEORIG=201811
AGREEMENT_NBR=aaa-4315 POL_SYNC=M27-9337 POL_TEST= PRIMANNU=775 PROFGAFF=SECRETAIRE COMPTABLE RAIS_SOC=IN SECTASSU=P SERVICE=
SOURCAFF=N STATUT=N TERR_REP=04 POLICE=aaa315- TERME=- PROVINCE=QC POL_CONV=P BROKER_GROUP_IND= PIP=1 POLICY=aaa4315 ANASS=6
NEWREN=R RCLASS2=COMMAUTO RCLASS2P=COMMIRCA PRIORCUR=C TRANS=DIR MOIS=202509 FPROV=QC. CIE=A TRANSFER=R RCLASS3=PERSAUTO
POLICY_INCEPTION_DT= POLICY_EXPIRY_DT= GENRE_GC= _ERROR_=1 _IORC_=1230015 _N_=1
How to see the value of each _IORC_
The WARNING is a result of preceding ERRORs, usually caused by invalid data. You need to check those.
I think that a _IORC_ value of zero means success, but that's a guess. As described in the documentation I linked, use %SYSRC to see the real numeric value for SOK.
The way to deal with that issue is to reset the _ERROR_ variable to zero (false).
See Example 15 in this documentation page.
Note that this method using INDEX and the KEY= option of the SET statement to do a lookup is still valid as far as I know and the way to handle cases where the lookup dataset is too large to load into a HASH object.
Not sure why they are writing the same data to two different datasets. You might find the answer to that by looking at what they do with the two datasets later in the program.
Make sure to reset the _ERROR_ flag when the SET with the KEY= sets the _IORC_ flag.
Here is a write up on doing look ups
https://support.sas.com/resources/papers/proceedings/proceedings/sugi25/25/po/25p234.pdf
Since all of the branches in the IF/THEN/ELSE tree have an OUTPUT statement you can just remove the OUTPUT statement and let the default output occur. So your data step might want to look like this instead:
data temp.auto temp.a;
set temp.a;
rclass3=rclass2;
if rclass2 = 'PERAUTO' then do;
set temp.histo_gc_auto_norisk key=compkey/unique;
if _iorc_ then do;
_error_=0;
end;
else do;
rclass2 ='COMMAUTO';
rclass2p='COMMIRCA';
end;
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.