Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Macros please

Status
Not open for further replies.

barryp

Programmer
Jan 30, 2002
48
0
0
GB
Hi

I have encapsulated the SET KEY= index lookup into a macro which tests _iosrc_ & returns a SUCCESS or Failure flag

My call is

%INDLOOK(SET=,KEY=,OPTION=)

the macro contains

set &SET key=&KEY &OPTION;

Question - I have a variable - myoption

Length myoption $ 9;

If i say

myoption='/unique';

and try

%INDLOOK(SET=MYSET,KEY=MYKEY,OPTION=myoption)

SAS complains about

File WORK.myoption.DATA not existing.

Help ??

Barry
 
Remember MACRO compiles before SAS runs the base code. So you MACRO resolves to myoption and not /unique as you would like. Perhaps you can explain what you need to do and I can suggest an alt method.
Klaz
 
OK. The basic problem. I have a macro as described above which I use to do an indexed lookup on a dataset of 250 million records of individuals

I am supplied with a list of individuals & need to , for each one, extract all their records (which then point on to other records in other datasets).

So I loop in a WHILE calling my macro until I get an _iosrc_ error saying there are no more records for this individual

On to the next individual. BUT it just could happen that the next individual in my input list is the SAME as the one before. Then I immediately get an _iosrc_ error. Wakat I thought was to use the OPTIONS param in the macro to set OPTION='\unique' for the FIRST call for each new input individual. (You can tell I'm really a C programmer)

I tried having 2 calls to the macro but that led me to my other problem (see 'Help with SET KEY=') where I hade 2 SET statements for the same dataset. . .



Barry
 
BarryP,
Do you need to get a recordset of all your lookups? Meaning do you have all the records (after your mac has run many times) stored in 1 table and then use it?

The reason I ask this is simple. If your goal is to process the results at on time you should focus on creating that record set. I see two tasks here. 1) You need to supply a unique list of names to the lookup function (program for SAS). 2) You need to use the aggragated data in a program of some sort.

If the presumtions above are correct, why not use the IN function on a WHERE statement. You may not be able to use your existing macro, but can query the main dataset (the large one) with the following.

In your data step---
data test;
set your_data;
where your_user_name in ("NAME1", "NAME2", "NAME1",.....);
run;

You can have repeats in the in statement.

If you have any other questions just ask.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top