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 (February 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 25 Feb 2010 15:18:15 -0600
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Sleazy trick making cats operate like bath catx and catt
Comments: To: xlr82sas <xlr82sas@aol.com>
In-Reply-To:  <180121f4-83a4-4b00-81b6-c142153cbcb2@a16g2000pre.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

Yes I realize that you were demonstrating the technique not how to create a LIBREF. I would prefer to used nested CAT functions, but I do see your point.

If I'm writing more that a little bit of code, I like to PUT/%INC it.

Don't always assume that spaces will causes problems, as shown by this example.

set sashelp . class ;

2606 data _null_; 2607 datavar = 'test'; 2608 ref = 'sashelp'; 2609 dset = 'class'; 2610 v1 = '$8'; 2611 cmd = catx(' ','data',datavar,'; set',ref,'.',dset,'; length var1',v1,';run;'); 2612 put cmd=; 2613 call execute(cmd); 2614 run;

cmd=data test ; set sashelp . class ; length var1 $8 ;run; NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds

NOTE: CALL EXECUTE generated line. 1 + data test ; set sashelp . class ; length var1 $8 ;run;

NOTE: Variable var1 is uninitialized. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.TEST has 19 observations and 6 variables.

On 2/25/10, xlr82sas <xlr82sas@aol.com> wrote: > On Feb 25, 6:25 am, iebup...@GMAIL.COM ("Data _null_;") wrote: > > Why would you CALL EXECUTE a LIBNAME when there is LIBNAME function? > > > > 542 data _null_; > > 543 lib='libname'; > > 544 ref='111'; > > 545 pth='/groundtruth/regusr/local/sd1'; > > 546 > > 547 /* libcmd=cats(lib,&sp,'s',ref,&sp,'"',pth,'";');*/ > > 548 /* put libcmd=;*/ > > 549 /* call execute(libcmd);*/ > > 550 > > 551 rc = libname(cats('S',ref),pth); > > 552 put rc=; > > 553 run; > > > > rc=-70008 > > > > On 2/24/10, xlr82sas <xlr82...@aol.com> wrote: > > > > > > > > > Hi SAS-Lers, > > > > > Most useful with call execute. > > > > > Suppose you have want to create the libname statement > > > > > %let sp='/**/ /**/'; /* this will insert a required space */ > > > > > data _null_; > > > lib='libname'; > > > ref='111'; > > > pth='/groundtruth/regusr/local/sd1'; > > > > > libcmd=cats(lib,&sp,'s',ref,&sp,'"',pth,'";'); > > > > > put libcmd=; > > > call execute(libcmd); > > > run; > > > > > NOTE: CALL EXECUTE generated line. > > > 1 + libname s111 "/groundtruth/regusr/local/sd1"; > > > NOTE: Library S111 does not exist.- Hide quoted text - > > > > - Show quoted text - > > > Hi data_null_, > > Good point. Not the best example. My point was to show how you can use > cats alone to do the functions of catx and catt. I find this quite > useful when I an sending a lot of text to call execute and some of the > strings require a space between the strings and some do not ie > > cmd=cats( > ,'data',&sp,datvar,';' /* note space after data > but no space after datvar */ > , 'set',&sp,ref,'.',dset,';' /* space between set and > ref but no spaces after that */ > , length,&sp,var1,';' >


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