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

 

How can I create add a column and if the ci_month date below is in this month then put a 0 and if it is in next month put a 1 and call the column W_Month

 

proc sql;

create table report5 AS SELECT

ci_month

from mydata

; quit;

 

example if today's date is 12/3/2015 and ci_month 20423 (which is 12/1/2015) then W_Month would be 1. If ci_month was 20454 (which is 1/1/2016) then W_Month would be 2.

 

1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10


proc sql;
create table report5 as
select case when ci_month-today()<=0 then 0
else 1 end as w_Month
from mydata;
quit;

View solution in original post

4 REPLIES 4
slchen
Lapis Lazuli | Level 10


proc sql;
create table report5 as
select case when ci_month-today()<=0 then 0
else 1 end as w_Month
from mydata;
quit;

Reeza
Super User
I think you want intck() function
Mattress58
Fluorite | Level 6

I came up with this

 

 

,case

when ci_month between INTNX('MONTH',TODAY(),0,'B') and INTNX('MONTH',TODAY(),0,'E') then 1

when ci_month between INTNX('MONTH',TODAY(),1,'B') and INTNX('MONTH',TODAY(),1,'E') then 2

when ci_month between INTNX('MONTH',TODAY(),2,'B') and INTNX('MONTH',TODAY(),2,'E') then 3

when ci_month between INTNX('MONTH',TODAY(),3,'B') and INTNX('MONTH',TODAY(),3,'E') then 4

when ci_month between INTNX('MONTH',TODAY(),4,'B') and INTNX('MONTH',TODAY(),4,'E') then 5

when ci_month between INTNX('MONTH',TODAY(),5,'B') and INTNX('MONTH',TODAY(),5,'E') then 6

else 0 end as mth_lst

Reeza
Super User
Try -> diff = intck('month', today(), '01Dec2015'd)+1;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 1194 views
  • 0 likes
  • 3 in conversation