BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

You have not supplied a sample data nor expected results.

You can remove first step and try next code:

proc sql;
  create table reportsummary as 
  select reportName, 
         count(key_num_acct) as reports_vol 
  from permdata.reportreferrals
  where reportDT = today() - 2. 
  group by reportName;
quit;

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

You have not supplied a sample data nor expected results.

You can remove first step and try next code:

proc sql;
  create table reportsummary as 
  select reportName, 
         count(key_num_acct) as reports_vol 
  from permdata.reportreferrals
  where reportDT = today() - 2. 
  group by reportName;
quit;
PaigeMiller
Diamond | Level 26

Macro variables SHOULD NOT be formatted.

 

data _null_;
    call symput('today',intnx('day',today(),-2));
run;

But @Shmuel has a simpler approach.

--
Paige Miller
Tom
Super User Tom
Super User

Why would you want to compare REPORTDT to a number that is less than 1 thousandths?  

 

625   data test;
626     x=31/07/2020 ;
627     put x=;
628   run;

x=0.0021923621

Isn't REPORTDT a DATE variable?  Wouldn't you want to compare it to another date value?   The date value for 31JUL2020 is 22127.

Either set the macro variable to the number of days. 

call symputX('today',today()-2);

Or set it to a string that the DATE informat can recognize and use it make a date literal in your later code.

call symputX('today',put(today()-2,date9.));
...
where reportDT = "&today"d

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1164 views
  • 1 like
  • 5 in conversation