Hi,
I have run the following codes fro days yet I could not get the result that i have been expecting.
The result that I had been expecting are more than 1 rows and yet it only stay as 1 rows despite the status of other rows are not in any of the above.
Please provide me with insights.
Thank you.
**Attached is the sas file that I had been running.
Post your program as text into the forum directly please.
%INCLUDE "/folders/myfolders/Folder1/sasmacro/array.sas";
%INCLUDE "/folders/myfolders/Folder1/sasmacro/do_over.sas";
%LET LIB_SOURCE=CH_P02_SOURCE_5;
%LET LIB_ODSCLAIM=DM_BASE.ODS_CLAIM;
DATA ODS_CLAIM;
SET ODS_CLAIM;
RUN;
PROC SQL;
CREATE TABLE CLAIMS_DETAILS AS
(
SELECT ID AS CLAIMID,ODS_CLAIM.POLICYNUMBER,PRODUCTC,CLAIMNUMBER,CLAIMNOTIFIEDDATE,STATUS,OCCURENCEDATE,LOSSTYPE,
TOTALPAIDAMOUNT,INTIMATEDDATE,DATEADMITTED,DATEDISCHARGED,
DATEAPPROVED,LOSSDESCRIPTION,TRANSACTIONNUMBER,APPROVEDAMOUNT,
LOSSDESCRIPTIONCODE,CLAIMENTRYDATE,CAUSEOFEVENTCODE,CLOSEDATE,LOSSDATE,ILLNESSCODE,ILLNESS
FROM ODS_CLAIM, (SELECT DISTINCT (POLICYNUMBER) FROM CH_P02_SOURCE_5) TEMP
Where ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER
and STATUS NOT IN ('Cancelled','Decline','Rejected'
,'Pending Assessment','Pending Authorization','Pending Documents')
)
;RUN; QUIT;
Can you post a PROC FREQ output from the STATUS column? And the FULL log.
And does the following change the results at all?
PROC SQL ;
CREATE TABLE CLAIMS_DETAILS AS
SELECT ID AS CLAIMID, ODS_CLAIM.POLICYNUMBER,
PRODUCTC, CLAIMNUMBER,CLAIMNOTIFIEDDATE, STATUS, OCCURENCEDATE, LOSSTYPE, TOTALPAIDAMOUNT,
INTIMATEDDATE, DATEADMITTED, DATEDISCHARGED, DATEAPPROVED, LOSSDESCRIPTION,
TRANSACTIONNUMBER, APPROVEDAMOUNT, LOSSDESCRIPTIONCODE, CLAIMENTRYDATE,
CAUSEOFEVENTCODE, CLOSEDATE, LOSSDATE, ILLNESSCODE, ILLNESS
FROM ODS_CLAIM full join
(SELECT DISTINCT (POLICYNUMBER) FROM CH_P02_SOURCE_5) as TEMP
on
ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER
where STATUS NOT IN ('Cancelled', 'Decline', 'Rejected', 'Pending Assessment', 'Pending Authorization', 'Pending Documents') ;
QUIT;
Hi,
The full join does not make any changes.
Attached is the requested files.
There's errors in your log. Fix the steps with the errors first - you truncated the log so I can't say where.
EDIT - the full log is there, didn't show in preview for some reason. Please do not use attachement but post things directly into the forum.
It's easier to work with. The answers the same still though, your SQL query has a syntax error, I think you need the word AS for the alias.
Fix that, and you'll likely at least be one step further. If there's an error in your log it helps if you state that at the start and include it, rather than us having to ask for it. And always read the log.
Sadly as someone else has mentioned we can't help without the data now.
Your code works, now, but the logic is wrong, since we don't know the logic you want, or the data you have and the code runs....
I would start with a couple of things - your first data step does nothing. Is that correct/expected?
Check the variable length for policy number, is it the same in both data sets? Are they character or numeric? If character does it have letter on both cases?
Remove the status filter in the query and see what the results are?
It is impossible to check your code without having the input (test) data and the macro source code.
I suggest:
1) check the log and locate the first step output with one row. Is it logic ?
Some intermediate output may have one row. Isn't it ?
Beyond:
1) Remark last step of PROC DELETE and rerun in order to have the intermediate datasets in work.
2) Check step by step output to locate first step suspicious output and recheck the code logic.
3) When you find a suspicious step, add some PUT statements and add info to the log ang debug it.
Recheck the log. If need change your step code and rerun that step until you feel it is ok.
4) Do the same recechecking on every suspicios step, up to the last.
Finally rerun the full updated code and check results.
5) Unmark the PROC DELETE step and save the code.
Does this help you?
I will give it a try. Thank you.
Checking your log:
First step resulted in 220 observations. The next step result with 1 observation only.
Is that fit your expectations?
Focus on the log lines numbered 467 - 480.
Check again your data - ODS_CLAIM dataset:
Try to run with part of the selection conditions:
WHERE ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER
(without checking STATUS). What statuses you have in the output? how many fit your second condition?
We may fail with logic or with the code.
Check your logic accrding to code and vice versa.
On second step there should have more than 1 row fits the criteria but unsure why it only shows a single row.
I genuinely suspect your first data step is logically incorrect. I suspect you should be sourcing the data from a library? Perhaps the one assigned in the macro variable.
Run next code and post your output as text:
%LET lib_source = ...; /* copmlete this statement ! */
PROC SQL;
CREATE TABLE CLAIMS_DETAILS AS
( SELECT ID AS CLAIMID,
ODS_CLAIM.POLICYNUMBER,
PRODUCTC,
CLAIMNUMBER,
CLAIMNOTIFIEDDATE,
STATUS,
OCCURENCEDATE,
LOSSTYPE,
TOTALPAIDAMOUNT,
INTIMATEDDATE,
DATEADMITTED,
DATEDISCHARGED,
DATEAPPROVED,
LOSSDESCRIPTION,
TRANSACTIONNUMBER,
APPROVEDAMOUNT,
LOSSDESCRIPTIONCODE,
CLAIMENTRYDATE,
CAUSEOFEVENTCODE,
CLOSEDATE,
LOSSDATE,
ILLNESSCODE,
ILLNESS
FROM ODS_CLAIM,
(SELECT DISTINCT(POLICYNUMBER) FROM &LIB_SOURCE.)
as TEMP
WHERE ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER
/*******
AND STATUS NOT IN ('Cancelled','Decline','Rejected'
,'Pending Assessment','Pending Authorization','Pending Documents')
*******/
);
QUIT;
PROC PRINT DATA=CLAIMS_DETAILS;
var STATUS ;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.