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