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

Hi all,

 

I have a program that I'm writing where I want to pull in data that has been added to the oracle dataset since the last time the program was run so that I can adjust paid medical claims to their final values.

 

To  do this, after the final adjusted claims are processed, I creat a table that contains the max paid date (pd_dt:  date format):


data final.claims_paid_thru_date (keep=pd_dt);
set claims_paid_thru_date;
if _STAT_ = 'MAX';
run;

 

This dataset has one record, with a pd_dt of Feb 23, 2019:

pic1.jpg 

The next time that I run the full program, I create a macro variable using data _null_ to collect that date:


data _null_ ;
set final.claims_paid_thru_date;
call symput('most_recent_pd_dt',pd_dt);
run;

 

Then I use that date to try and extract everything from the source that has a newer paid date:

 

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt "&most_recent_pd_dt"
);
quit;

 

This is the error I get:

ERROR: Expression using greater than (>) has components that are of different data types.

 

I assume that proc sql can't handle the sas macro variable.

 

Is there some way that I can get around this so that the program doesn't need me to enter the date by hand each time?

 

Thanks so  much!

Barb

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Did you check what's in the macro variable?

 

It's likely the unformatted value so it will work if you remove the quotation marks. 

 

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt  &most_recent_pd_dt
);
quit;

 

Or change how you create the macro variable, I recommend the first option. 

 

data _null_ ;
set final.claims_paid_thru_date;
call symput('most_recent_pd_dt',put(pd_dt, date9.));
run;

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt "&most_recent_pd_dt"d
);
quit;

@BRKS wrote:

Hi all,

 

I have a program that I'm writing where I want to pull in data that has been added to the oracle dataset since the last time the program was run so that I can adjust paid medical claims to their final values.

 

To  do this, after the final adjusted claims are processed, I creat a table that contains the max paid date (pd_dt:  date format):


data final.claims_paid_thru_date (keep=pd_dt);
set claims_paid_thru_date;
if _STAT_ = 'MAX';
run;

 

This dataset has one record, with a pd_dt of Feb 23, 2019:

pic1.jpg 

The next time that I run the full program, I create a macro variable using data _null_ to collect that date:


data _null_ ;
set final.claims_paid_thru_date;
call symput('most_recent_pd_dt',pd_dt);
run;

 

Then I use that date to try and extract everything from the source that has a newer paid date:

 

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt "&most_recent_pd_dt"
);
quit;

 

This is the error I get:

ERROR: Expression using greater than (>) has components that are of different data types.

 

I assume that proc sql can't handle the sas macro variable.

 

Is there some way that I can get around this so that the program doesn't need me to enter the date by hand each time?

 

Thanks so  much!

Barb


 

View solution in original post

2 REPLIES 2
Reeza
Super User

Did you check what's in the macro variable?

 

It's likely the unformatted value so it will work if you remove the quotation marks. 

 

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt  &most_recent_pd_dt
);
quit;

 

Or change how you create the macro variable, I recommend the first option. 

 

data _null_ ;
set final.claims_paid_thru_date;
call symput('most_recent_pd_dt',put(pd_dt, date9.));
run;

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt "&most_recent_pd_dt"d
);
quit;

@BRKS wrote:

Hi all,

 

I have a program that I'm writing where I want to pull in data that has been added to the oracle dataset since the last time the program was run so that I can adjust paid medical claims to their final values.

 

To  do this, after the final adjusted claims are processed, I creat a table that contains the max paid date (pd_dt:  date format):


data final.claims_paid_thru_date (keep=pd_dt);
set claims_paid_thru_date;
if _STAT_ = 'MAX';
run;

 

This dataset has one record, with a pd_dt of Feb 23, 2019:

pic1.jpg 

The next time that I run the full program, I create a macro variable using data _null_ to collect that date:


data _null_ ;
set final.claims_paid_thru_date;
call symput('most_recent_pd_dt',pd_dt);
run;

 

Then I use that date to try and extract everything from the source that has a newer paid date:

 

proc sql;
create table claims.sql_claims_new as

(select *

from CCW.CLM_LN_MED_MV

where PD_DT gt "&most_recent_pd_dt"
);
quit;

 

This is the error I get:

ERROR: Expression using greater than (>) has components that are of different data types.

 

I assume that proc sql can't handle the sas macro variable.

 

Is there some way that I can get around this so that the program doesn't need me to enter the date by hand each time?

 

Thanks so  much!

Barb


 

BRKS
Quartz | Level 8

Thank you so much!

Ugh...  I usually use that macro variable as part of a path name, hence the double quotes...

Sorry for the trouble and thanks!  That worked!  🙂

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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