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

I have this problem because I have a promt set for which picks the report date for me, I select it with where in proc sql. However, it also needs to create a table where I will compare with the previous last date. What function to use for this?

%let gv_date_dly=%sysevalf(%bquote('&date_dly.'d));

this is the code for selecting the actual results,

proc sql;
create table zabcheck as
select 
sum(zab_hip) as hip_curr
,zab_data_spr as date_curr
from _mart.zab_kred 
where zab_data_spr=&gv_date_dly. and zab_hip = 1
group by zab_data_spr
;
quit;

And i would like to create table where

where zab_data_spr=&gv_date_dly.  will be for previous date ( always last day of month)

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
%let date_dly = 15nov2021;

%let gv_date_dl = %sysfunc(intnx(month,%sysevalf("&date_dly."d),-1,e));

%put &=gv_date_dl;

%put %sysfunc(putn(&gv_date_dl.,yymmdd10.));

The last two statements are for control purposes only.

View solution in original post

3 REPLIES 3
Gieorgie
Quartz | Level 8
Exactly, every day of the report until the last day of the month.
Kurt_Bremser
Super User
%let date_dly = 15nov2021;

%let gv_date_dl = %sysfunc(intnx(month,%sysevalf("&date_dly."d),-1,e));

%put &=gv_date_dl;

%put %sysfunc(putn(&gv_date_dl.,yymmdd10.));

The last two statements are for control purposes only.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 430 views
  • 1 like
  • 2 in conversation