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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 875 views
  • 0 likes
  • 3 in conversation