|
Wow...3000 separate invocations of PROC SQL...I don't think this would
perform well.
As I and others have posted, I bet Paula's approach is flawed, and wouldn't
require a macro approach.
Having said that, using SQL, I would do the following (untested, I don't
have SAS on my home laptop!!!)
libname foo excel "path to Excel file";
proc sql noprint;
select name into :var1 - :var999999 from dictionary.columns where
upcase(libname) = "FOO" and upcase(memname) = "SHEET1";
quit;
%let totnum = &sqlobs;
"Mary" <mlhoward@avalon.net> wrote in message
news:047d01c8f3ef$85f1aa80$832fa8c0@HP82083701405...
> Here's a SQL approach; you would have to put whatever code you are using
> with the macro variables (I'm not sure I want to know....) inside the
> macro
> that created them.
>
> data test;
> informat varname $20.;
> input varname;
> obsnum + 1;
> cards;
> variable1
> variable2
> variable3
> ;
>
> %Macro docalls;
> %Local I;
> proc sql noprint;
> select count(*) into :model_count
> from test;
> quit;
> %Do I = 1 %To &model_count;
> proc sql noprint;
> select varname into :varname&i
> from test
> where obsnum=&i;
> quit;
>
> %End ;
> %put &varname1;
> %put &varname2;
> %Mend docalls ;
>
> -Mary
> ----- Original Message -----
> From: sophe88@yahoo.com
> To: SAS-L@LISTSERV.UGA.EDU
> Sent: Friday, August 01, 2008 10:16 AM
> Subject: parse varlist to generic macro variables
>
>
> Hi,
>
> Have a macro variable
>
> %let source1=
> firstname
> lastname
> zip
> address
> timezone;
>
> Want to
> %let var1=firstname;
> %let var2=lastname;
> %let var3=zip;..
>
> This is just example. I have >3000 variables. So I don't want to type
> or use concatenate function in Excel to do many lines. So far I ran
> proc contents, then proc sql, select into: var 1 - var9999. Finally
> add %let totvar=&sqlobs;
>
> Any way I can skip proc content and act directly on &source1, get var1
> to var9999 and still get totvar dynamically? Thanks
>
> Paula
|