Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2005, 02:53 PM
Ian Whitlock
Guest
 
Posts: n/a
Default Re: How to select list of attributes in PROC SQL by using macro

Toby,

There is no harm in illustrating good design principles when
giving the answer. Thus isolate the problem.

%macro mklist ( pref=A_ , from = 1 , to = 1 , sep = %str(,)) ;
%local i list ;
%do i = &from %to &to ;
%let list = &list&sep &pref&i ;
%end ;
%substr(&list,2)
%mend ;

Then Mark could use in many different SQL situations.

proc sql;
select %mklist(pref=a_,to=20) from table_name;
quit;

Ian Whitlock
=================
Date: Fri, 17 Jun 2005 02:39:16 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion"
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: How to select list of attributes in PROC SQL by
using macro
variables
Comments: To: joystar.jin@GMAIL.COM
In-Reply-To:
<1118969589.523359.142670@g43g2000cwa.googlegroups .com>
Content-Type: text/plain; format=flowed
Mark ,
For you viewing entertainment:
%macro alpha ;
%local var_list i ;
data one ;
array test (5) a_1-a_5 ;
do i = 1 to 5 ;
test(i) = i ;
output ;
end ;
run ;
%do i = 1 %to 4 ;
%let var_list = &var_list A_&i , ;
%end ;
proc sql ;
select &var_list i
from one ;
quit ;
%mend ;
%alpha

Toby Dunn


From: Mark <joystar.jin@GMAIL.COM>
Reply-To: Mark <joystar.jin@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to select list of attributes in PROC SQL by using
macro
variables
Date: Thu, 16 Jun 2005 17:53:09 -0700
I need to use PROC SQL to select a list of variables in my macro
program.
The list of variables are in the form of
A1, A2,.....,A20
I need to refer to them by using following macro variable as:
A_&index1 - A_&index2
where index1 and index2 are macro variables.
Can I do following in PROC SQL?
proc sql;
select A_&index1 - A_&index2 from table_name;
quit;
Otherwise, is there a way to do it in SAS?
Thanks,
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: invoking a macro with nested macros within a sas proc Rushi Patel Newsgroup comp.soft-sys.sas 0 08-22-2007 04:44 PM
Re: macro variable created via a macro's proc sql select into doe Joe Whitehurst Newsgroup comp.soft-sys.sas 0 09-04-2006 06:04 AM
Re: Sudoku Solver - Proc SQL (somewhat long) Paul M. Dorfman Newsgroup comp.soft-sys.sas 1 05-10-2006 05:12 PM
Re: Sudoku Solver - Proc SQL (somewhat long) Choate, Paul@DDS Newsgroup comp.soft-sys.sas 0 05-10-2006 03:34 PM
Sudoku Solver - Proc SQL (somewhat long) Hoyle, Larry Newsgroup comp.soft-sys.sas 0 05-10-2006 02:41 PM



All times are GMT. The time now is 08:34 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.