Hello! I did a proc compare statement to find out the percent difference between a variable in CB_DB3 and CBHSOB, to try to validate the new data against data from our database. There are many comparisons that are less than a 1% difference, due to rounding errors, so I want to change those to 0's. I have attached a screenshot of the output I am referring to. I am trying to figure out a way to say "if -1 < * < 1 then *=0". Basically, I want to look at every observation in the dataset and if the observation is between -1 and 1 then change it to 0, so that I can see which observations and variables I need to take a closer look at. I tried to figure out how to do a macro or a do loop to have it look at all variables, since I have over 100 variables and would like to try to avoid writing them all out. I have been researching this issue for hours, and the closest example I came across is below, however, I would still have to type out every 100+ variable name plus &variablename. Is there any better way of doing this? %macro mac1(inc=,firm=); /* Small, useless macro for illustrative purposes */ %put in macro mac1 inc= &inc firm= &firm; %mend mac1; /* Step 1: copy values of INCOME and COMPANY to macro variables for all observations in which INCOME is greater than 0 */ data _null_; set two end=last; where income gt 0; call symput('income'|| compress(put(_n_,3.)), compress(put(income,11.2))); call symput('company'|| compress(put(_n_,3.)), trim(left(company))); if last then call symput('num_values', compress(put(_n_,3.))); run; /* Step 2: call macro MAC1 once for each set of values of INCOME and COMPANY that were written to macro variables */ %macro macloop1; %local j; %do j = 1 %to &num_values; Thank you!!
... View more