LOG:
Variables used as boolean have to be numeric. 0 = false, non-zero values = true. So assign 0 or 1 instead of '0' and '1'.
About your exclusion problem: find observations that should be included but aren't, and run them through your code "manually" (pencil&paper).
Variables used as boolean have to be numeric. 0 = false, non-zero values = true. So assign 0 or 1 instead of '0' and '1'.
About your exclusion problem: find observations that should be included but aren't, and run them through your code "manually" (pencil&paper).
You have a critical typo in the program. Your top loop :
Do until (last.ID);
But inside the loop, the BY statement reads:
BY MRN;
Those are not consistent, and illogical. The only reason you get no error message is because of the bottom DO loop, which actually does create last.ID.
Also, note that @Kurt_Bremser is correct. If you don't want variables convered to numeric, a good solution is often to create them as numeric yourself:
if ...... then a=1;
if ....... then ct=1;
Once you put quotes around the "1" you are creating them as character, which later forces SAS to convert them back to numeric.
Yes, definitely fixed that typo and removed the quotations and that part of the code is working. I'm currently going through the data manually to see which values are not being read. This way I can try and figure out why I'm losing so many observations
Thank you for all the help!
A useful bit of SAS coding knowledge:
Instead of
if not missing (alteration) then a='1';
you can use
a = not missing (alteration);
It's easy to create Boolean values:
data junk; input x; a= not missing(x); b = x ge 3; datalines; 1 . 3 44 ; run;
Just be sure that if only want a value when a certain condition occurs that you have and IF / then assignment otherwise every record has either 0 or 1.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.