Thank you Paige and all of you who responded me with this thread!!!
I think we won't know what the exact issue it is until we see the portion of the data. Enclosed is the portion of the variable with trailing space from what I understand. Actually, it could be leading spaces or tab or return/enter or whatever. You can see from the Excel file that I uploaded. If you find there are two 'identical' values, there must be one without a trailing space and one with it, such as 'Atrial Fibrillation' and 'Atrial Fibrillation '. When I created dummy variable, SAS can only recognize the first 'Atrial Fibrillation'---the one without the trailing space after text. Same issues happened with 'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema '. Because the variable doesn't have the value of this one without the trailing space, it only showed up once, but it still has a trailing space that I want to remove.
I have used the following syntax to generate the dummies, but realized that SAS doesn't recognize those ones with trailing spaces:
data have;
set want;
if significant_conditions in
('Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema ',
'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity ',
'Atrial Fibrillation',
'Atrial Fibrillation ',
'Cardiomegaly',
'Cardiomegaly ',
'Atherosclerotic and Hypertensive Cardiovascular Disease ',
'Atherosclerotic and Hypertensive Cardiovascular Disease') then heart_disease=1;
if significant_conditions in
('Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema ',
'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity ') then Alcoholism=1;
if significant_conditions in
('Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema ',
'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity ') then obesity=1;
if significant_conditions in
('Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema ',
'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity ') then respiratory_disease=1;
run;
... View more