@sufiya wrote:
question, if I wanted to combine 2 months together like October & November - is that possible? using the Case.
thank you again!
case month(Date_Bought) when 10 and 11 then Bought end as Date_Bought_OctDec
You can use a CASE statement, but not in that way. That statement is looking for data bought in January, not October or December. '10 and 11' is an boolean expression. Since both 10 and 11 are not zero then it is always true so it has a value of 1.
You can either use two WHEN clauses
case month(Date_Bought)
when 10 then Bought
when 12 then Bought
end as Date_Bought_OctDec
Or put the test in the WHEN clause.
case when month(Date_Bought) in (10,11) then Bought
end as Date_Bought_OctDec
thank you @Tom that worked too!
Question, what logic is needed to insert zero '0' into the blank rows/variables?
tried adding the following to CASE,
else if column=. then column=0 end as October
but receiving an error. please help ....
IF isn't valid in SQL, try replacing it with WHEN instead.
Thank you! worked with when and not if
question, if I wanted to combine 2 months together like October & November - is that possible? using the Case.
thank you again!
case month(Date_Bought) when 10 and 11 then Bought
end as Date_Bought_OctDec
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.