BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Barite | Level 11 woo
Barite | Level 11

Hi Tom -  i am using your code and it is giving me below error message...

____________________________________________________________________________________________________

29            indsname=indsname   ;   where date ne today()-2 ; dsname=indsname ; run

                      _

                      22

                      76

29       ! ;

ERROR 22-322: Syntax error, expecting one of the following: END, KEY, KEYS, NOBS, POINT. 

ERROR 76-322: Syntax error, statement will be ignored.

Reeza
Super User

Start small, do it manually first, without macros and then convert it to a macro.

Also what version of SAS do you have, indsname isn't available in SAS 9.1 for example, it is in SAS 9.2+.

Change the following so you reference several of your data sets instead of what I have and see if it gives you what you want. Then work from there.

data test ;

  length indsname dsname $256 ;

  set

*list some of our datasets here instead;

dir1.rep1

dir2.rep1

dir3.rep1

  indsname=indsname

  ;

  where date ne today()-2 ;

dsname=indsname ;

run;

woo
Barite | Level 11 woo
Barite | Level 11

Hi, i understand this logic at some extent but if below is how i can test code at lower scale then i am receiving same error;

libname rep1 "f:\woo\dir1\test_datasets";

libname rep2 "f:\woo\dir2\test_datasets";

libname rep3 "f:\woo\dir3\test_datasets";

data test ;

  length indsname dsname $256 ;

  set

       rep1.test_check

       rep2.test_check

       rep3.test_check


  indsname=indsname

  ;

  where date ne today()-2 ;

dsname=indsname ;

run;

Reeza
Super User
Also what version of SAS do you have, indsname isn't available in SAS 9.1 for example, it is in SAS 9.2+.


Post your full log with errors (not just the error) from above code if you're still having errors and are on SAS 9.2+

woo
Barite | Level 11 woo
Barite | Level 11

yes i am using 9.1

Reeza
Super User

12 year old unsupported software isn't a great idea in general.

Try this:

data test ;

  length indsname dsname $256 ;

  set

       rep1.test_check (in=a)

       rep2.test_check (in=b)

       rep3.test_check (in=c)

  ;

  where date ne today()-2 ;

dsname=a*1+b*2+c*3 ; /*1=rep1, 2=rep2, 3=rep3*/

run;

woo
Barite | Level 11 woo
Barite | Level 11

Thank you so much all.

Reeza it worked fine and i was able to convert it into macro. as below. tested - ran fine.

%macro test;

data test;

length indsname dsname $256;

set

%do i=1 %to 10;

"f:\woo\dir&i.\test_datasets\test_check"

%end;

;

  where date ne today()-2 ;

dsname=indsname ;

run;

%mend;

%test

art297
Opal | Level 21

Woo: I don't see how that could have provided anything but missing values for both dsname and indsname. Your code didn't follow Reeza's suggested code.  I'd still like to know why the other code versions didn't work.

woo
Barite | Level 11 woo
Barite | Level 11

i tested code from my last post and it worked fine. I also did try with different logic like   where date ne today()-3 ; and it worked fine too.

i didn't make any major changes for macro piece of code that i have posted and i still have doubt on (dsname=indsname) (last 4th line of code from what i have posted) so i don't know what line in macro code should replace this dsname=a*1+b*2+c*3 ; from simple data step perspective but i simply used dsname=indsname; and it worked...

Reeza
Super User

If you're on SAS 9.1 there's no way that works.

Tom
Super User Tom
Super User

If it does what you need then great.  It is hard for me to tell as I still have no idea what you are actually trying to do.

But if you are using 9.1 then it could not have pulled the names of the contributing datasets into the new table since INDSNAME option is not available and you didn't use it anyway.

woo
Barite | Level 11 woo
Barite | Level 11

I am using 9.1

I assigned "SAS_MAIN"  -->  right click on it ---> properties   ---> "software" tab and i can see that "SAS Version" is 9.1

woo
Barite | Level 11 woo
Barite | Level 11

Tom - this was the question.

i have 10 different directories (like below). under each directory have dataset name "test_check". Our process (other code) producing these "test_check" dataset in 10 directories where we have one variable "date" (type=numeric) which has value like "Sat, Feb 28, 2015" with format "weekdate17." (this value is from today's process - tomorrow it will be"Sun, Mar 01, 2015"). Now basically all the time this dataset, "test_check" has same value for all 10 datasets (i.e two days back: Sat, Feb 28, 2015) but sometime lets say 2 out of 10 datasets has different value, i want to find out in which directory "date" variable has different value than lets say Sat, Feb 28, 2015 (if i run code today).

__________________________________

f:\woo\dir1\test_dataset\test_check

f:\woo\dir2\test_dataset\test_check

.

.

.

f:\woo\dir10\test_dataset\test_check

Tom
Super User Tom
Super User

If you just have 10 directories to check then forget macro code and just write the program. Use your editor to replicate the lines that are similar.

To find out if the dates do not match each other you don't need to know if they match today's date.

data check ;

    merge

     "f:\woo\dir1\test_dataset\test_check" (rename=(date=date1))

     "f:\woo\dir2\test_dataset\test_check" (rename=(date=date2))

....

     "f:\woo\dir10\test_dataset\test_check" (rename=(date=date10))

    ;

    if N(of date1-date10) < 10 or min(of date1-date10) ne max(of date1-date10);

    put (date1-date10) (=/);

run;

woo
Barite | Level 11 woo
Barite | Level 11

Tom it worked great but can you please brief me about

why we put this sign?(=/);

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 46 replies
  • 2198 views
  • 6 likes
  • 8 in conversation