From: Muthia Kachirayan on
Nicole,

You seem to declare numeric array and use its elements in INDEX() function.
INDEX() function needs only character arguments.

On Mon, Dec 14, 2009 at 8:34 PM, Nicole Bibb
<nicole.bibb(a)blueshieldca.com>wrote:

> I still can't get this to work correctly. I need to get cvar(j) and the
> others to resolve into a macro variable name. I tried to concate it with
> the name but still didnot work. Any new suggestions...
>
> data hits;
> set tempfile;
>
> array cvar(2324) roscol1-roscol2324;
> array tvar(2324) rostab1-rostab2324;
> array svar(2324) sno1-sno2324;
>
> do j=1 to &total_count;
>
> if index(theline2,cvar(j))>0 and index(theline2,tvar(j))> 0 then do;
> %* only gets here if an occurance found ;
> Path = "&Path";
> Program = "&Program";
> Owner = "&Owner";
> LINE=svar(j);
> output;
> %* if only need one hot per file then quit ;
> *stop;
> end;
> end;
> run;
>
From: Tom Abernathy on
I do not understand what you are trying to do.
- If you want to generate a macro variables, you should use the CALL
SYMPUT statement. For example you could add.
call symputx('LINEnumber',j);
call symputx('LINE',cvar(j));

- If you want to save the values of the macro variables into dataset
variables then it looks like you have the right statements. If you
want to save the values from the array that triggered the find then
assign them to new variables. For example you could add:
_cvar = cvar(j);
_tvar = tvar(j);
_svar = svar(j);


- Perhaps your problem is how to stop the loop? You can use the STOP
statement like you have commented out if you want to totally stop the
data step. Or if you just want to just stop the loop then use the
LEAVE statement.



On Dec 14, 7:34 pm, nicole.b...(a)BLUESHIELDCA.COM (Nicole Bibb) wrote:
> I still can't get this to work correctly. I need to get cvar(j) and the
> others to resolve into a macro variable name. I tried to concate it with
> the name but still didnot work.  Any new suggestions...
>
> data hits;
>    set tempfile;
>
>    array cvar(2324) roscol1-roscol2324;
>    array tvar(2324) rostab1-rostab2324;
>    array svar(2324) sno1-sno2324;
>
>    do j=1 to &total_count;
>
>       if index(theline2,cvar(j))>0 and index(theline2,tvar(j))> 0 then do;
>             %* only gets here if an occurance found ;
>         Path = "&Path";
>         Program = "&Program";
>         Owner = "&Owner";
>   LINE=svar(j);
>         output;
>             %* if only need one hot per file then quit ;
>         *stop;
>      end;
>   end;
> run;

From: Patrick on
May be this will work?

data hits;
set tempfile;
retain Path "&path" Program "&Program" Owner "&Owner";
array cvar(2324) roscol1-roscol2324;
array tvar(2324) rostab1-rostab2324;
array svar(2324) sno1-sno2324;
do j=1 to dim(svar);
if index(theline2,strip(put(cvar(j),8.))) and index(theline2,strip
(put(tvar(j),8.))> 0 then do;
LINE=svar(j);
output;
%* if only need one hot per file then quit ;
*stop;
end;
end;
run;

HTH
Patrick
From: "Schwarz, Barry A" on
Give us a chance to help you. "Did not work" describes nothing but your dissatisfaction. What was your output? What were you expecting?

What debugging steps have you taken? Can you add some debugging PUT statements to show the values of variables as you loop through the observations?

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Nicole Bibb
Sent: Monday, December 14, 2009 4:34 PM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: help w do loop

I still can't get this to work correctly. I need to get cvar(j) and the
others to resolve into a macro variable name. I tried to concate it with
the name but still didnot work. Any new suggestions...

data hits;
set tempfile;

array cvar(2324) roscol1-roscol2324;
array tvar(2324) rostab1-rostab2324;
array svar(2324) sno1-sno2324;

do j=1 to &total_count;

if index(theline2,cvar(j))>0 and index(theline2,tvar(j))> 0 then do;
%* only gets here if an occurance found ;
Path = "&Path";
Program = "&Program";
Owner = "&Owner";
LINE=svar(j);
output;
%* if only need one hot per file then quit ;
*stop;
end;
end;
run;