BookmarkSubscribeRSS Feed
HTG
Calcite | Level 5 HTG
Calcite | Level 5

 Hi, I am writing the below mentioned codes to churn out results from a data set with a specific date range. I set the date as 15dec2015 to get results for 01dec2015 to 31dec2015. The majority of the churned result are from dec2015 but consists some of the earlier result from 2012 to Nov 2015. Can you advise on how I can get the churned results only from dec2015? Below is the code:

 

libname mis_data "E:\GCC Data Mart\Monthly MIS\Unsecured\FE_Deck\Data"

 

%let setdt='15DEC2015'd;

 

data _null_;

curr=intnx('month',&setdt,0);

curr=intnx('day',curr,-1);

   

call symput("yymm",put(curr,yymmn4.));

call symput("yyyymmdd",put(curr,yymmddn8.));

call symput("dt",compress("'"||put(curr,date9.)||"'"||"d"));

run;

 

%put &yymm &yyyymmdd &dt;

3 REPLIES 3
Reeza
Super User

You need to show your filter as well. How you use the macro variables matters. 

PGStats
Opal | Level 21

Assuming your data includes a SAS date variable (say myDate), all you need is to add the statement

 

where myDate between intnx("MONTH", &setdt, 0, "BEGINNING") and intnx("MONTH", &setdt, 0,"END");

 

to your data step, or the clause

 

where myDate between intnx("MONTH", &setdt, 0, "BEGINNING") and intnx("MONTH", &setdt, 0,"END")

 

to your SQL query.

 

If your date variable is a SAS datetime, replace "MONTH" by "DTMONTH".

PG
HTG
Calcite | Level 5 HTG
Calcite | Level 5

Thanks PG.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1219 views
  • 0 likes
  • 3 in conversation