Re: Macro help please

i tried this but i am getting all 10 sas datasets (ana1 to ana10) where some datasets doens't has any value for variable "date" and some datasets (2 actually) where has value for "date" variable which is satisfying "IF" condition.

Isn't it we supposed to get only those 2 datasets where date value is not matching.

Re: Macro help please

_n_ is an counter for how many times the data step loop has iterated. In your example, it will always be > 0.

If you are trying to implement Reeza's suggestion, that won't do it. You would need an %IF statement (as he mentioned), to test whether or not there are 0 records that meet your criterion, and then only generate the data step code if there are > 0 records.

Re: Macro help please

Actually it is still giving me all 10 datasets from 10 directories with zero observation on it.

Let me conform i have "test_check" dataset in 10 different directory with one variable "date" which has value "Wed, Feb25, 2015". For now i have same value for all datasets so basically output of above code logic would be nothing- none dataset should be created since "if" condition is not satisfying.