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 (October 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 28 Oct 2009 17:57:38 -0700
Reply-To:     xlr82sas <xlr82sas@AOL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject:      Re: Is there a function to count the number of distinct
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

On Oct 28, 1:22 pm, RandyHerbi...@WESTAT.COM (Randy Herbison) wrote: > I don't think you can have inline SCL, but creating & compiling SCL in batch is possible. > > A SOURCE entry can be %INCLUDEd in an SCL entry. If the %INCLUDE could specify a range of lines for the SOURCE entry, avoiding the non SCL which would cause a compile error, it would be possible to include the SCL source in the same program that runs it. > > -Randy > > > > -----Original Message----- > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Data _null_; > Sent: Wednesday, October 28, 2009 2:49 PM > To: SA...@LISTSERV.UGA.EDU > Subject: Re: Is there a function to count the number of distinct > > I want to code and call all in the batch or DMS environment. > Bypassing the whole PROC BUILD code/comple/test interactive steps. > Something like this seems reasonable. > > proc build c=....; > parmcards4; > init: > <more scl.....> > return; > ;;;; > run; > > proc display c=...; > > On 10/28/09, Randy Herbison <RandyHerbi...@westat.com> wrote: > > SCL has the LVARLEVELS function to get distinct values. > > > In addition to using PROC DISPLAY to run SAS/AF programs between other steps, you can create a user-defined function to run SAS/AF programs within a data step. That makes it easy to pass values between a data step and SCL. One way to do it uses the PROC FCMP's RUN_MACRO function. Wrap a PROC DISPLAY step in a macro and the rest is the same as using the RUN_MACRO function to run any other macro as a user-defined function. > > > -Randy > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Data _null_; > > Sent: Wednesday, October 28, 2009 1:01 PM > > To: SA...@LISTSERV.UGA.EDU > > Subject: Re: Is there a function to count the number of distinct > > > SCL would be nice if you could code and execute it in the SYSIN stream > > like any other data or proc step. > > > I believe Richard DeVenezia showed us how to do that last year. > > > On 10/28/09, montura <montura...@gmail.com> wrote: > > > That's easy if you have SCL. > > > > public list dataVector / (sendEvent='N'); > > > > use the insertc function to place icn1 thru icn5 into the list named > > > dataVector. > > > use the sort function: sort(dataVector, 'nodup''); > > > > With duplicates removed, its simple to know how many are distinct. > > > > unique=listlen(dataVevtor); > > > use SQL insert statement in a submit block or putvarn to place the > > > results in a SAS dataset.- Hide quoted text - > > - Show quoted text -

Hi,

I have a rather hokey techinique that allows SCL code to be edited, complied and tested interactivly in SAS display manager. No pointing and clicking required.

see http://homepage.mac.com/magdelina/.Public/utl.html

utl_createscl.txt

It is hokey because I create a SCL program that converts my SAS Display manager SCL code into a runable SCL entry

filename catout "c:\runscl\pgm2scl.sas7bcat" recfm=f lrecl=50; /* code to create sas7bdat - windows specific This is the hokey part when a create an SCL utility program from binary data. If there is interest I can show how I created this binary ifo */

/* contents cat.pgm2scl */ libname cat "c:\runscl"; proc catalog cat=cat.pgm2scl; contents; run;quit;

# Name Type Create Date

1 PROGRAM SCL 13AUG2009:09:15:42 */

/* compile program program to covert SAS display manager code */ proc build catalog=cat.pgm2scl batch; compile select=program et=scl; run;

/* compile program */ proc build catalog=cat.pgm2scl batch; compile select=program et=scl; run; /* NOTE: Compiling PROGRAM.SCL. NOTE: Code generated for PROGRAM.SCL. Code size=1044 NOTE: PROCEDURE BUILD used (Total process time): real time 3.07 seconds cpu time 0.09 seconds */

data _null_; file 'c:\runscl\procrun.scl'; input; put _infile_; cards4; dcl char(12) xname _xname; init: dsid=open('class_v'); if dsid then do; do while (fetch(dsid)=0); x=getvarn(dsid,varnum(dsid,'x')); submit continue; proc sql; select 'X' || name into :_xname from class where x=&x; quit; endsubmit; xname=getvarc(dsid,varnum(dsid,'xname')); _xname=symget('_xname'); put xname= _xname=; end; dsid=close(dsid); end; submit; %symdel _xname; endsubmit; return; ;;;; run;

/***************************************************************/ /* */ /* copy the scl program to the scl catalog */ /* */ /* Call the progra.scl code like this */ /* %let srcFile=c:\runscl\procrun.scl; */ /* %let dstEntry=work.tmp.copy.scl; */ /* proc display catalog=cat.prg2scl.program.scl; */ /* run; */ /* */ /***************************************************************/

/* you need to use these macro variables look at PROGRAM.SCL */ %let srcFile=c:\runscl\procrun.scl; %let dstEntry=work.tmp.copy.scl; proc display catalog=cat.pgm2scl.program.scl; run;quit;

/* demostrate running proc sql inside a datastep */ %symdel _xname; data class_v / view=class_v; set sashelp.class; x=_n_; if symexist('_xname') then xname=symget('_xname'); put 'XXXXXXXXXXXXXXXXXX'; run;

data class; set sashelp.class; x=_n_; run;

/* compile scl program */ proc build catalog=work.tmp batch; compile select=copy et=scl; run;

/* finally run the SCL program */ Proc Display c=work.tmp.copy.scl ; run ;


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