Hello,
I have a dataset that I need to export based on a condition and can’t get it to work. I have the below code that runs but doesn’t export the right dataset. When the variable case_nr has a value for any observation then I want to export just those observations else export the whole dataset. It seems simple enough but when I test it my dataset has a record that has a value in the field case_nr it still exports everything instead of just that observation. Likewise, I would expect to receive the full dataset when none of the observations have a value in case_nr.
DATASET: ME.ALL_MEM_BKS
ACCT
NUMBER
TYPE
AMOUNT
CASE_NR
ADDR
ADDR1
ADDR2
123456
123
PRIMARY
1.25
123
LANE
185795
456
PRIMARY
3.95
987132
43
DRIVE
987562
789
PRIMARY
2.85
924
STREET
PROC SQL NOPRINT;
SELECT COUNT(*) INTO :MISSINGCOUNT
FROM ME.ALL_MEM_BKS
WHERE CASE_NR = '';
QUIT;
%IF &MISSINGCOUNT > 0 %THEN %DO;
%PUT &MISSINGCOUNT;
%TCPWIN;
%SYSLPUT BK_PATH = &BK_PATH;
%SYSLPUT ISSUE = &ISSUE;
RSUBMIT;
%LET BKFILE = ISSUE_&ISSUE._BANKRUPTCY;
PROC EXPORT DATA=ME.ALL_MEM_BKS
OUTFILE="&BK_PATH\&BKFILE..XLSX"
DBMS = XLSX REPLACE;
SHEET="BK_FILE";
RUN;
ENDRSUBMIT;
SIGNOFF;
%END;
%ELSE %DO;
%PUT &MISSINGCOUNT;
PROC SQL NOPRINT;
CREATE TABLE ALL_MEM_BK1 AS
SELECT *
FROM ME.ALL_MEM_BKS
WHERE CASE_R IS NOT NULL;
QUIT;
%IF %SYSFUNC(EXIST(ALL_MEM_BK1)) %THEN %DO;
%TCPWIN;
%SYSLPUT BK_PATH = &BK_PATH;
%SYSLPUT ISSUE = &ISSUE;
RSUBMIT;
%LET BKFILE = ISSUE_&ISSUE._BANKRUPTCY;
PROC EXPORT DATA=ALL_MEM_BK1
OUTFILE="&BK_PATH\&BKFILE..XLSX"
DBMS = XLSX REPLACE;
SHEET="BK_FILE";
RUN;
ENDRSUBMIT;
SIGNOFF;
%END;
... View more