LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Apr 2008 16:02:53 -0400
Reply-To:     Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:      Re: Macro variable is not long enough to hold my intended value
Comments: To: SUBSCRIBE SAS-L Dan <deniseyu001@GMAIL.COM>
In-Reply-To:  <200804161943.m3GFgFC2000402@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Dan: The macrovariable testvar contains the 20 strings that you have written to mockdata, though perhaps not in the order that you expect. Try %macro getdt ; data mockdata ; %do i=1 %to 20 ; i=&i; x=quote(trim(left("This is variable number &i"))) ; output ; %end ; run; %mend ; %getdt

proc print ; run;

proc sql noprint ; select distinct x into :testvar separated by ',' from mockdata order by i; quit ;

%put &testvar;

S

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of SUBSCRIBE SAS-L Dan Sent: Wednesday, April 16, 2008 3:44 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Macro variable is not long enough to hold my intended value

Hi. SasLers:

Please help:

%macro getdt ; data mockdata ; %do i=1 %to 20 ; x=quote(trim(left("This is variable number &i"))) ; output ; %end ; run; %mend ; %getdt

proc print ; run;

proc sql noprint ; select distinct x into :testvar separated by ',' from mockdata; quit ;

data _null_ ; %put Macro variable "Testvar" is >>>&testvar<<<< ; run;

Here is the partial log:

Macro variable "Testvar" is >>>"This is variable number 1","This is variable number 10","This is variable number 11","This is variable number 12","This is variable number 13","This is variable number 14","This is variable number 15","This is variable number 16","This is variable number 17","This is variable number 18","This is variable number 19","This is variable number 2","This is variable number 20","This is variable number 3","This is variable number 4","This is variable number 5","This is variable number 6","This is variable number 7","This is variable number 8","This is variable number 9"<<<<

I wanted, however, is that the macro variable &Testvar to hold value until "This is variable number 20"

Thanks.

Dan


Back to: Top of message | Previous page | Main SAS-L page