Date: Mon, 15 Jun 2009 14:20:22 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: help with macros
I don't know what's in the data and I'm not sure what you want to do with
&IND and &table. Eg. is it ok to get a 2-level name from the function
call? Or should it be a single (work)-dataset name? In that case you can
change the left translate string, eg _ instead of . Otherwise you need a
LIBNAME for FINANCE!
Maybe better:
%let table=F%sysfunc(translate(&ind, '___',', -'));
Also all other special characters which cannot be part of a datasetname
must be replaced, eg. with _
%let ind =%str(FINANCE,REAL ESTATE) ;
%let table=F%sysfunc(translate(&ind, '.__',', -'));
%put &ind;
%put &table;
/*or even something like*/
/*%let table==substrn( &ind.,1,3);*/
proc sql;
create table &table. as
select *
from dm.nyse_open_old
where industry='&ind.'
last but not least: the macro variable &ind is not resolved between
quotes, must be double-quotes:
where industry="&ind."
Hope that works.
Gerhard
On Mon, 15 Jun 2009 10:55:32 -0700, tal <talila.ar@GMAIL.COM> wrote:
>Hi,
>I have a list of industries such as "FOODS, BEVERAGES-
>BEVERAGES","FINANCE,REAL ESTATE"
>
>I'd like to do something like
>
>%let ind =FINANCE,REAL ESTATE ;
>%let table=fFINANCE,REAL ESTATE ;
>
>
>/*or even something like*/
>/*%let table==substrn( &ind.,1,3);*/
>
>proc sql;
>create table &table. as
>select *
>from dm.nyse_open_old
>where industry='&ind.'
>;
>
>quit;
>
>
>None of these macro work. In the table name it doesn't work because of
>the " , - " etc.
>The ind macro doesn't work as well, i don't undestand why
> but it doesn't recognize what I want it to recognize.
>It's important for me that the tables will have a name that I can
>easily identify- so i don't want to change it to something like
>"table1"
>
>
>Also if you could help me with my last question at - I'd really
>appriceate:
>
>
>http://groups.google.com/group/comp.soft-
sys.sas/browse_frm/thread/8a3a19443a824a69/ddff2935e7312284#ddff2935e731228
4
>Thanks,
>Tal
|