BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kayla_Tan222
Calcite | Level 5

Hi, I want to do do a loop to repeat my code for many files (different years and month)

and in between, I need to save the sas table record as intermediary.

I check that if I do not include the %macro, my libname was correct and will be exist in the library. my %macro loop should be correct also since iable to get the results if I remove the libname statement. I unable to find my mistake.

 

is there any wrong with my code? The system keep saying that the library POLACLM does not exist

 

/*Import POLA_clm_mth_201812*

**Folder:D:\POLA\2018\201812\CSV*/

%Macro POLA_clm_mth_(YYYY,YYYYMM);

libname polaclm '\\kaiwksgh415thw5\Data\POLA\&YYYY\&YYYYMM\DBF\';

 

Data polaclm.POLA_clm_mth_&YYYYMM;

%let _EFIERR_=0;

infile "\\kaiwksgh415thw5\Data\claims\POLA\source\POLA_clm_mth_&YYYYMM..csv" dlm=',' MISSOVER DSD lrecl=32767 firstobs=2;

informat rskcoy 1.;

informat zmajrsk $3.;

informat rsktyp $3.;

informat zbusnsrc 3.;

informat rskpfx $2.;

informat chdrnum $10.;

informat poltrnno 4.;

informat risktype $3.;

informat ccdate 8.;

informat crdate 8.;

informat rskno 3.;

informat dteeff 8.;

informat ztrnno 4.;

informat zsumsi 16.0;

informat clmpfx $2.;

informat clmcoy 1.;

informat claim $10.;

informat datocc 8.;

informat tranno 4.;

informat clntpfx $2.;

informat clntcoy 2.;

informat clntnum 10.;

informat acctyr 4.0;

informat acctmnth 2.0;

informat batctrcde $5.;

informat batcbrn $2.;

informat clstat 2.;

informat payflg $2.;

informat trndsc $30.;

informat reqnno $10.;

informat receipt $10.;

informat zclmos best16.2;

informat zclmpd best16.2;

informat zosqs best16.2;

informat zpdqs best16.2;

informat zosvc best16.2;

informat zpdvc best16.2;

informat zosaf best16.2;

informat zpdaf best16.2;

informat zossp01 best16.2;

informat zossp02 best16.2;

informat zossp03 best16.2;

informat zossp04 best16.2;

informat zossp05 best16.2;

informat zossp06 best16.2;

informat zpdsp01 best16.2;

informat zpdsp02 best16.2;

informat zpdsp03 best16.2;

informat zpdsp04 best16.2;

informat zpdsp05 best16.2;

informat zpdsp06 best16.2;

informat zosfac01 best16.2;

informat zosfac02 best16.2;

informat zpdfac01 best16.2;

informat zpdfac02 best16.2;

informat zosfri best16.2;

informat zpdfri best16.2;

informat zoscout best16.2;

informat zpdcout best16.2;

 

 

format rskcoy 1.;

format zmajrsk $3.;

format rsktyp $3.;

format zbusnsrc 3.;

format rskpfx $2.;

format chdrnum $10.;

format poltrnno 4.;

format risktype $3.;

format ccdate 8.;

format crdate 8.;

format rskno 3.;

format dteeff 8.;

format ztrnno 4.;

format zsumsi 16.0;

format clmpfx $2.;

format clmcoy 1.;

format claim $10.;

format datocc 8.;

format tranno 4.;

format clntpfx $2.;

format clntcoy 2.;

format clntnum 10.;

format acctyr 4.0;

format acctmnth 2.0;

format batctrcde $5.;

format batcbrn $2.;

format clstat 2.;

format payflg $2.;

format trndsc $30.;

format reqnno $10.;

format receipt $10.;

format zclmos best16.2;

format zclmpd best16.2;

format zosqs best16.2;

format zpdqs best16.2;

format zosvc best16.2;

format zpdvc best16.2;

format zosaf best16.2;

format zpdaf best16.2;

format zossp01 best16.2;

format zossp02 best16.2;

format zossp03 best16.2;

format zossp04 best16.2;

format zossp05 best16.2;

format zossp06 best16.2;

format zpdsp01 best16.2;

format zpdsp02 best16.2;

format zpdsp03 best16.2;

format zpdsp04 best16.2;

format zpdsp05 best16.2;

format zpdsp06 best16.2;

format zosfac01 best16.2;

format zosfac02 best16.2;

format zpdfac01 best16.2;

format zpdfac02 best16.2;

format zosfri best16.2;

format zpdfri best16.2;

format zoscout best16.2;

format zpdcout best16.2;

 

 

INPUT

rskcoy

zmajrsk $

rsktyp $

zbusnsrc

rskpfx $

chdrnum $

poltrnno

risktype $

ccdate

crdate

rskno

dteeff

ztrnno

zsumsi

clmpfx $

clmcoy

claim $

datocc

tranno

clntpfx $

clntcoy

clntnum

acctyr

acctmnth

batctrcde $

batcbrn $

clstat

payflg $

trndsc $

reqnno $

receipt $

zclmos

zclmpd

zosqs

zpdqs

zosvc

zpdvc

zosaf

zpdaf

zossp01

zossp02

zossp03

zossp04

zossp05

zossp06

zpdsp01

zpdsp02

zpdsp03

zpdsp04

zpdsp05

zpdsp06

zosfac01

zosfac02

zpdfac01

zpdfac02

zosfri

zpdfri

zoscout

zpdcout;

 

if _ERROR_ then call symputx('_EFIERR_',1);

 

 

ccdate=input(put(ccdate,Z8.),yymmdd8.);

format ccdate yymmddn8.;

crdate=input(put(crdate,Z8.),yymmdd8.);

format crdate yymmddn8.;

dteeff=input(put(dteeff,Z8.),yymmdd8.);

format dteeff yymmddn8.;

datocc=input(put(datocc,Z8.),yymmdd8.);

format datocc yymmddn8.;

 

 

 

zclmosnet=sum(zclmos,-zosqs,-zosvc,-zosaf,-zossp01,-zossp02,-zossp03,-zossp04,-zossp05,-zossp06,-zosfac01,-zosfac02,-zosfri,-zoscout);

zclmpdnet=sum(zclmpd,-zpdqs,-zpdvc,-zpdaf,-zpdsp01,-zpdsp02,-zpdsp03,-zpdsp04,-zpdsp05,-zpdsp06,-zpdfac01,-zpdfac02,-zpdfri,-zpdcout);

 

 

if month(datocc)=12 then

lossyr_fy=year(datocc)+1;

 

else

lossyr_fy=year(datocc);

if acctmnth=12 and acctyr<=2014 then

accyr_fy=acctyr+1;

 

else

accyr_fy=acctyr;

if acctmnth=12 and acctyr<=2014 then

accmth_fy=1;

else if acctmnth^=12 and acctyr<=2014 then

accmth_fy=acctmnth+1;

 

else

accmth_fy=acctmnth;

dev7yr_fy=min(accyr_fy-lossyr_fy,7);

dev10yr_fy=min(accyr_fy-lossyr_fy,10);

 

run;

%mend Pola_clm_mth_;

%POLA_clm_mth_(2016,201601);

%POLA_clm_mth_(2016,201602);

RUN;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
heffo
Pyrite | Level 9

Single quotes! 

SAS does not look for macro references between single quotes ( ' ). Change them to double quotes ( " ) around the path in your libname statement and it should work. 🙂

View solution in original post

3 REPLIES 3
heffo
Pyrite | Level 9

Single quotes! 

SAS does not look for macro references between single quotes ( ' ). Change them to double quotes ( " ) around the path in your libname statement and it should work. 🙂

Kayla_Tan222
Calcite | Level 5

Hi Heffo,

 

I'm facing a problem after successfully running the code.

i get two intermediary in my local pc (the path i save)

however , only the file 201602 is in my library server . 201601 was missing in the library. How can i solve this?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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