**Edit:** Hopefully this will clear things up - I'm attaching the code: data test1; input visit $16.; datalines; First Second ; data nulll; input index $; datalines; . ; data test2; stop; set nulll; run; data test; set test2 test1; if index(VISIT, 'Fir')^=0 then do; index='100'; end; proc print data=test; run; Alternatively, the code works properly if phrased as data test1; input visit $16.; datalines; First Second ; data nulll; input index $; datalines; . ; data test2; stop; set nulll; run; data test; set test2 test1; run; data test; set test; if index(VISIT, 'Fir')^=0 then do; index='100'; end; proc print data=test; run; Hello everyone, I stumbled across an odd phenomenon and was wondering whether a more experienced user could shed some light on the topic. Suppose I want to assign '1' (as a character) to an indicator variable if a condition is met and I want it to be missing otherwise. I also want to have the names of the variables fixed for which I created a dummy empty dataset (called emptydata) with the appropriate names of the variables that will be generated. The code itself looks like this: data work_data; set empty_data prep_data; if (condition) then indicator='1'; where prep_data is a dataset containing data we already have, empty_data is there just for the naming and indicator is a variable NOT present in any of the datasets. There, however, seems to be a problem - the indicator trivially becomes '1' for all observations regardless of the condition. If, on the other hand, I used the following code: data work_data; set empty_data prep_data; data work_data; set work_data; if (condition) then indicator='1'; then things seem to be normal, that is, if I split it into 2 data steps (I might be wrong though). Has anyone experience something like that? Any help will be appreciated. All the best, teli4
... View more