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;
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
can someone plz help with logic?
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;
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
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, ^=, |, ||, ~=.
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.