Hello All,
Hope you can help me with below code. I'm using Case When Function in SAS, and I want to combine those two variables to display one output table. My code as below, there's no error when I run the code but the second variable does not produce any data when its run. Is "AND" can be used to combine both variables?
SQL;
CREATE TABLE WORK.ScribeDeadZone1 AS
SELECT t1.SubId,
as Location,
as ScribeIndex,
as Measurement,
/* SPULaser */
CASE
WHEN EquipmentID = 2825 and 2859 THEN 'KLM11P2'
WHEN EquipmentID = 2827 and 2861 THEN 'KLM11P3'
Give an example of the dataset that you have and what you want your output to be. The way you are writing this doesn't make sense.
Its invalid code (assuming equipmentid is numeric):
/* SPULaser */
CASE
WHEN EquipmentID in (2825,2859) THEN 'KLM11P2'
WHEN EquipmentID in (2827,2861) THEN 'KLM11P3'
ELSE "Not found" end as NEW_VARIABLE
By invalid I mean the case doesn't actually create anything as its missing the end as variable.
Put in the implied parenthesis to see why your syntax does not work.
WHEN ( (EquipmentID = 2825) and 2859) THEN 'KLM11P2'
2859 is always TRUE (SAS treats any non-zero value as TRUE).
So you are only testing if EQUIPMENTID is equal to 2825.
Use the IN operator.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.