Dear Cynthia,
I'll try to explain better... let's make an example close to yours:
I'd like to create the file only if height_sum gt 150 but I want to be certain the every value in the table (of height_sum) is gt 150:
I do not want to select, in the table, values of height_sum gt 150 and delete all other values.
I want to keep every value gt 150 only if every value in height_sum is gt 150.
If there's at least one value lt 150 I don't want the table to be created at all.
I'm trying to use this code referring to the table created in the output with no conditions:
proc tabulate data=sashelp.class out=default;
class age;
var height;
table age,
height*sum height*mean;
run;
%macro del_(ds,Var,n);
proc sql noprint;
select sum(&Var<&n) into :ctrl from &ds;
%if ctrl >0 %then drop table &ds;;
quit;
%mend del_;
With the tabulate above I obtain this ds (here is the proc print of the ds work.defalut created by the tabulate):
Height_ Height_
Oss Age _TYPE_ _PAGE_ _TABLE_ Sum Mean
1 11 1 1 1 108.8 54.4000
2 12 1 1 1 297.2 59.4400
3 13 1 1 1 184.3 61.4333
4 14 1 1 1 259.6 64.9000
5 15 1 1 1 262.5 65.6250
6 16 1 1 1 72.0 72.0000
%del_(default,height_sum,150);/*ok, table not saved (work.default is deleted)*/
I n the case n=150 I'd like the table not to be saved, because in height_sum there are two values < 150 (Oss number 1 and Oss number 6): that's what sas correctly does!
If I change the value n in the macro from 150 to 70 I'd like the table to be saved (because no value in height_sum is <70) but unfortunately it doesn't: in any case sas deletes the table...
%del_(default,height_sum,70);/*KO, table not saved (work.default is deleted) --this is not what I want--*/
I'm surely making some mistakes in the code, but I can't find where (I don't know weel proc sql..).
Many thanks in advance
D
... View more