Desktop productivity for business analysts and programmers

check datasets in dif directory - staking error - send out in attachment in email

Reply
Super Contributor
Super Contributor
Posts: 331

check datasets in dif directory - staking error - send out in attachment in email

Hi friends -  please help.


I have one same SAS dataset (dataset name: test) getting generated in 10 directories. In "test" dataset i have one variable (date) which has value as "Wed, Feb 18, 2015", (same value on all 10 "test" dataset). i wants to check if any test dataset doesn't has value as today's date format. For instance if i am running code today i wants to see which "test" dataset has different value than "Wed, Feb 18, 2015" and wants to create datasets with list of directory and then will export same to me.  (lets say if i don't have "Wed, Feb 18, 2015" value for "test" dataset under "dir1" and "dir9" then one dataset, for example "output_test" should be generated which has one variable (name any) with value "dir1" and "dir9"



d:\woo\dir1\test ("test" is SAS dataset)

d:\woo\dir2\test

d:\woo\dir3\test

.

.

.

d:\woo\dir10\test


I am thinking like this but not sure.

%macro mycheck;

libname fin&i. "d:\woo\dir&i.";

%do i=1 %to 10;

data woo;

set fin&i..test;

format date weekdate17.;

%if date ne &sysdate. %then

    %do;

        /*create dataset which shows which test dataset under specific directory not having today's date*/

  %end;

%end;

%mend;

%mycheck;

PROC Star
Posts: 1,143

Re: check datasets in dif directory - staking error - send out in attachment in email

Hi, Woo

It's not bad; the concept is sound, and it generally looks okay. There's about a million ways to do this, but yours should work. A couple of comments:

Your libname statement needs to be inside your %do loop.

No need to make the library names different in each iteration; the only variable element is the directory name, which you've taken care of.

I'm not setting up an environment to run your code, but I believe it will be running properly fairly quickly.

Tom

Super Contributor
Super Contributor
Posts: 331

Re: check datasets in dif directory - staking error - send out in attachment in email

can someone plz help with logic?

Super Contributor
Super Contributor
Posts: 331

Re: check datasets in dif directory - staking error - send out in attachment in email

below logic is giving me everything (all 10 sas dataset name with dif&i. + 10 datasets with woo&i. - instead it supposed to give only two dataset where date variable is not equal to today in my case)

%macro mycheck;

%do i=1 %to 10;

libname fin&i. "d:\woo\dir&i.";

data woo&i.  dif&i.;

set fin&i..test;

%if date ne &sysdate. %then

    %do;

        output dif&i.;

  %end;


%end;

%mend;

%mycheck;

PROC Star
Posts: 1,143

Re: check datasets in dif directory - staking error - send out in attachment in email

Hi, Woo

First, change

%if date ne &sysdate. %then

    %do;

        output dif&i.;

  %end;

to

if date ne &sysdate. then

    do;

        output dif&i.;

  end;

The first version is using the macro processor, which you don't want to do. Your dataset references are a little confused, they may need some work.

Keep working through it...you're close.

Tom

Super Contributor
Super Contributor
Posts: 331

Re: check datasets in dif directory - staking error - send out in attachment in email

actually it's not helping - i am using below code and getting error: ALSO - JUST TO MAKE SURE I HAVE DATE value = Fri, Feb 20, 2015

%macro mycheck;

%do i=1 %to 10;

libname fin&i. "d:\woo\dir&i.";

data woo&i.  dif&i.;

set fin&i..test;


if date ne &sysdate. then

    do;

        output dif&i.;

  end;


%end;

%mend;

%mycheck;

_____________________________

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>,

              =, >, ><, >=, AND, EQ, GE, GT, LE, LT, MAX, MIN, NE, NG, NL, OR, ^=, |, ||, ~=.

Super Contributor
Super Contributor
Posts: 331

Re: check datasets in dif directory - staking error - send out in attachment in email

either this logic is not working

%macro mycheck;

%do i=1 %to 10;

libname fin&i. "d:\woo\dir&i.";

data woo&i. ;

set fin&i..test;

    call symput ("fdate", put("&sysdate"d, weekdate17.));

    if date ne &fdate. then

         do;

              output woo&i.;

         end;

run;


%end;

%mend;

%mycheck;

Ask a Question
Discussion stats
  • 6 replies
  • 417 views
  • 0 likes
  • 2 in conversation