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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 323 views
  • 1 like
  • 2 in conversation