- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-26-2021 05:49 PM
(2541 views)
Hello team,
I need to use or statement in a case statement. It keeps giving me errors:
Proc sql; create table mytable as; select a.*, b* , case when (a.diagcode1 <150 and a.diagcode2 <12) then 'no more' case when missing(a.diagcode) or missing(a.diacode2) then 'non existent' else ' ' end as 'new stata' from a Left join b...
what is the problem?
Regards
blueblue
Blue Blue
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this - but please remember to post your SAS log including errors as we aren't mind readers 😉
Proc sql;
create table mytable as
select a.*, b* ,
case when (a.diagcode1 <150 and a.diagcode2 <12) then 'no more'
when missing(a.diagcode) or missing(a.diacode2) then 'non existent'
else ' '
end as new_stata
from a Left join b...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
1. Too many CASE (twice, should only be once) One CASE per new variable being created.
2. Too early semicolon - no semicolon after the AS on the CREATE TABLE clause
3. Order of operations. SAS puts numeric missing as the lowest values so if you first check if the values are < 12 and 150 and both are missing you'll get them coded into "no more" when it should be in non existent.
Those are for starters...there could be more.
2. Too early semicolon - no semicolon after the AS on the CREATE TABLE clause
3. Order of operations. SAS puts numeric missing as the lowest values so if you first check if the values are < 12 and 150 and both are missing you'll get them coded into "no more" when it should be in non existent.
Those are for starters...there could be more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
And if there are errors in your code include them in the post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Also
as 'new stata'
should be
as 'new strata'n
PG