BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ajulio4
Obsidian | Level 7

Hello,

i have a macro variable  in numeric. like &jour = 23040,

In CAS i try to find line where dateColumn > &jour bu i have the error :

ERROR: Operator is not unique: DATE > INTEGER

 

Can someone help me plz.

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

FedSQL is pretty strictly ANSI compliant. Expressions require date constants to be written in ANSI-standard format -  DATE'YYYY-MM-D'. The raw SAS date number must be formatted properly and surrounded by single quotes. You can use PUTN to format the value, but the dashes will be misinterpreted as a minus sign if you use  %SYSFUNC to execute the PUTN function, and macro code won't execute if surrounded by single quotes. 

  1. Use QSYSFUNC to mask the dashes in the formatted text.
  2. Use the %TSLIT macro to allow the macro code to resolve before adding the necessary single quotes.

Example:

 

data jours;
  input jour;
datalines;
23038
23039
23040
23041
23042
;

%let Aujourdhui=23040;
proc FedSQL;
select * 
	from jours
	where jour>=date%tslit(%qsysfunc(putn(&Aujourdhui,yymmddd10.)));
;
quit;

Hope this helps.

 

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

2 REPLIES 2
SASJedi
SAS Super FREQ

FedSQL is pretty strictly ANSI compliant. Expressions require date constants to be written in ANSI-standard format -  DATE'YYYY-MM-D'. The raw SAS date number must be formatted properly and surrounded by single quotes. You can use PUTN to format the value, but the dashes will be misinterpreted as a minus sign if you use  %SYSFUNC to execute the PUTN function, and macro code won't execute if surrounded by single quotes. 

  1. Use QSYSFUNC to mask the dashes in the formatted text.
  2. Use the %TSLIT macro to allow the macro code to resolve before adding the necessary single quotes.

Example:

 

data jours;
  input jour;
datalines;
23038
23039
23040
23041
23042
;

%let Aujourdhui=23040;
proc FedSQL;
select * 
	from jours
	where jour>=date%tslit(%qsysfunc(putn(&Aujourdhui,yymmddd10.)));
;
quit;

Hope this helps.

 

Check out my Jedi SAS Tricks for SAS Users
ajulio4
Obsidian | Level 7

Hello. thks you so much. It helps and it works

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 365 views
  • 4 likes
  • 2 in conversation