Converting SAS code

  • Permalink
  • submit to reddit
  • Email
  • Follow


  We have reached a point where our SAS code is taking enormous
amounts of time to execute. The size of the data sets together with
the nature of the algorithms require days and almost weeks to
completion in some instances. My boss has therefore opened up the idea
of using high performance computing in other languages.

  How do you convert for example a merge command between three sets? I
paste a sample from one of the programs below to give you an idea of
some operations. Please add your ideas on how we can do this more
efficiently.

  DATA a(sgio=yes);

         LENGTH tmin tmax aar 3; /* tre bytes */

         LENGTH cram $ 1;

         RETAIN tmin 0;



         SET libt.crami;  /* pnr aar ugenr ugegrad ugears */

         WHERE MOD(pnr, 10) = &pnrcif;



         BY pnr aar ugenr;



         IF first.aar THEN DO;

                 tmin = ugenr;

         END;

         IF last.aar THEN DO;

                 tmax = ugenr;

     /*            cram = '1';*/

                 OUTPUT;

         END;

         KEEP pnr aar tmin tmax;

/* indeholder: pnr aar tmin tmax cram */

PROC PRINT data=a(obs=500);

run;



/* laver en record for alle personer for alle ?r */



/* indeholder: pnr aar */



/* inds?tter status fra ida, beregner cramstatus for alle ?r og
beregner tmin/tmax for ?r med cram=0 */

DATA b(sgio=yes);

         LENGTH aar 3;

         MERGE libt.pnraar a(IN=cram1) libt.statusi (KEEP = pnr aar
status selvst alder);

         BY pnr aar;

         /*%include '/data2/700730/spells/program/pnrfilter.sas';*/

         WHERE MOD(pnr, 10) = &pnrcif;

                IF cram1=0 THEN DO;

                 cram = '0';

                 tmin = 53;  /* tmin s?ttes til den sidste uge i ?ret +1 */

                 IF aar IN (1986, 1992, 1997, 2003) THEN tmin = 54;

                 tmax = 0;

                END;

                ELSE cram = '1';



                /* antager, at manglende ida-oplysninger om status betyder, at
personen ikke er i arbejdsstyrken */

         IF status = . THEN status = 0;

                IF selvst = . THEN selvst = 0;

RUN;

                /* indeholder: pnr aar tmin tmax status cram */



DATA a; RUN;

DATA pnraar; RUN;



/* beregner nu arbejdsstilling og cramstatus for foreg?ende ?r */

DATA c(sgio=yes);

         LENGTH tmaxprev statprev aar 3;

         RETAIN tmaxprev 0;

         RETAIN statprev 0;

         RETAIN cramprev '0';

                RETAIN selvstprev 0;



         SET b;

         tmaxprev = lag(tmax);

         statprev = lag(status);

         cramprev = lag(cram);

                selvstprev = lag(selvst);



                IF aar = 1985 THEN DO;    /* tilstand for 1984 s?ttes lig tilstand
for 1985 */

                 tmaxprev=tmax;

                 statprev=status;

                 cramprev=cram;

                                selvstprev=selvst;

         END;

RUN;
0
Reply hlane (5) 11/28/2009 3:44:37 PM

See related articles to this posting


Maybe, you could improve the performance of your SAS algorithms.
Sometimes very simple changes make significant performance
improvement.  Doing so would seem easier than rewriting in a new
language.  Poorly optimized algorithms probable run about the same
speed in any language.

If you would tell the group about the overall process we could
probably help you improve your existing SAS programs.   The code
snippet you supplied does not proved much information.


On 11/28/09, Håkan Lane <hlane@cls.dk> wrote:
>  We have reached a point where our SAS code is taking enormous
> amounts of time to execute. The size of the data sets together with
> the nature of the algorithms require days and almost weeks to
> completion in some instances. My boss has therefore opened up the idea
> of using high performance computing in other languages.
>
>  How do you convert for example a merge command between three sets? I
> paste a sample from one of the programs below to give you an idea of
> some operations. Please add your ideas on how we can do this more
> efficiently.
>
>  DATA a(sgio=yes);
>
>        LENGTH tmin tmax aar 3; /* tre bytes */
>
>        LENGTH cram $ 1;
>
>        RETAIN tmin 0;
>
>
>
>        SET libt.crami;  /* pnr aar ugenr ugegrad ugears */
>
>        WHERE MOD(pnr, 10) = &pnrcif;
>
>
>
>        BY pnr aar ugenr;
>
>
>
>        IF first.aar THEN DO;
>
>                tmin = ugenr;
>
>        END;
>
>        IF last.aar THEN DO;
>
>                tmax = ugenr;
>
>    /*            cram = '1';*/
>
>                OUTPUT;
>
>        END;
>
>        KEEP pnr aar tmin tmax;
>
> /* indeholder: pnr aar tmin tmax cram */
>
> PROC PRINT data=a(obs=500);
>
> run;
>
>
>
> /* laver en record for alle personer for alle ?r */
>
>
>
> /* indeholder: pnr aar */
>
>
>
> /* inds?tter status fra ida, beregner cramstatus for alle ?r og
> beregner tmin/tmax for ?r med cram=0 */
>
> DATA b(sgio=yes);
>
>        LENGTH aar 3;
>
>        MERGE libt.pnraar a(IN=cram1) libt.statusi (KEEP = pnr aar
> status selvst alder);
>
>        BY pnr aar;
>
>        /*%include
> '/data2/700730/spells/program/pnrfilter.sas';*/
>
>        WHERE MOD(pnr, 10) = &pnrcif;
>
>               IF cram1=0 THEN DO;
>
>                cram = '0';
>
>                tmin = 53;  /* tmin s?ttes til den sidste uge i ?ret +1 */
>
>                IF aar IN (1986, 1992, 1997, 2003) THEN tmin = 54;
>
>                tmax = 0;
>
>               END;
>
>               ELSE cram = '1';
>
>
>
>               /* antager, at manglende ida-oplysninger om status betyder, at
> personen ikke er i arbejdsstyrken */
>
>        IF status = . THEN status = 0;
>
>               IF selvst = . THEN selvst = 0;
>
> RUN;
>
>               /* indeholder: pnr aar tmin tmax status cram */
>
>
>
> DATA a; RUN;
>
> DATA pnraar; RUN;
>
>
>
> /* beregner nu arbejdsstilling og cramstatus for foreg?ende ?r */
>
> DATA c(sgio=yes);
>
>        LENGTH tmaxprev statprev aar 3;
>
>        RETAIN tmaxprev 0;
>
>        RETAIN statprev 0;
>
>        RETAIN cramprev '0';
>
>               RETAIN selvstprev 0;
>
>
>
>        SET b;
>
>        tmaxprev = lag(tmax);
>
>        statprev = lag(status);
>
>        cramprev = lag(cram);
>
>               selvstprev = lag(selvst);
>
>
>
>               IF aar = 1985 THEN DO;    /* tilstand for 1984 s?ttes lig
> tilstand
> for 1985 */
>
>                tmaxprev=tmax;
>
>                statprev=status;
>
>                cramprev=cram;
>
>                               selvstprev=selvst;
>
>        END;
>
> RUN;
>
0
Reply iebupdte 11/28/2009 4:29:16 PM

On Nov 28, 8:44=A0am, hl...@CLS.DK (H=C3=A5kan Lane) wrote:
> =A0 We have reached a point where our SAS code is taking enormous
> amounts of time to execute. The size of the data sets together with
> the nature of the algorithms require days and almost weeks to
> completion in some instances. My boss has therefore opened up the idea
> of using high performance computing in other languages.
>
> =A0 How do you convert for example a merge command between three sets? I
> paste a sample from one of the programs below to give you an idea of
> some operations. Please add your ideas on how we can do this more
> efficiently.
>
> =A0 DATA a(sgio=3Dyes);
>
> =A0 =A0 =A0 =A0 =A0LENGTH tmin tmax aar 3; /* tre bytes */
>
> =A0 =A0 =A0 =A0 =A0LENGTH cram $ 1;
>
> =A0 =A0 =A0 =A0 =A0RETAIN tmin 0;
>
> =A0 =A0 =A0 =A0 =A0SET libt.crami; =A0/* pnr aar ugenr ugegrad ugears */
>
> =A0 =A0 =A0 =A0 =A0WHERE MOD(pnr, 10) =3D &pnrcif;
>
> =A0 =A0 =A0 =A0 =A0BY pnr aar ugenr;
>
> =A0 =A0 =A0 =A0 =A0IF first.aar THEN DO;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmin =3D ugenr;
>
> =A0 =A0 =A0 =A0 =A0END;
>
> =A0 =A0 =A0 =A0 =A0IF last.aar THEN DO;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmax =3D ugenr;
>
> =A0 =A0 =A0/* =A0 =A0 =A0 =A0 =A0 =A0cram =3D '1';*/
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0OUTPUT;
>
> =A0 =A0 =A0 =A0 =A0END;
>
> =A0 =A0 =A0 =A0 =A0KEEP pnr aar tmin tmax;
>
> /* indeholder: pnr aar tmin tmax cram */
>
> PROC PRINT data=3Da(obs=3D500);
>
> run;
>
> /* laver en record for alle personer for alle ?r */
>
> /* indeholder: pnr aar */
>
> /* inds?tter status fra ida, beregner cramstatus for alle ?r og
> beregner tmin/tmax for ?r med cram=3D0 */
>
> DATA b(sgio=3Dyes);
>
> =A0 =A0 =A0 =A0 =A0LENGTH aar 3;
>
> =A0 =A0 =A0 =A0 =A0MERGE libt.pnraar a(IN=3Dcram1) libt.statusi (KEEP =3D=
 pnr aar
> status selvst alder);
>
> =A0 =A0 =A0 =A0 =A0BY pnr aar;
>
> =A0 =A0 =A0 =A0 =A0/*%include '/data2/700730/spells/program/pnrfilter.sas=
';*/
>
> =A0 =A0 =A0 =A0 =A0WHERE MOD(pnr, 10) =3D &pnrcif;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF cram1=3D0 THEN DO;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cram =3D '0';
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmin =3D 53; =A0/* tmin s?ttes til den=
 sidste uge i ?ret +1 */
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IF aar IN (1986, 1992, 1997, 2003) THE=
N tmin =3D 54;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmax =3D 0;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 END;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ELSE cram =3D '1';
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* antager, at manglende ida-oplysninger =
om status betyder, at
> personen ikke er i arbejdsstyrken */
>
> =A0 =A0 =A0 =A0 =A0IF status =3D . THEN status =3D 0;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF selvst =3D . THEN selvst =3D 0;
>
> RUN;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* indeholder: pnr aar tmin tmax status c=
ram */
>
> DATA a; RUN;
>
> DATA pnraar; RUN;
>
> /* beregner nu arbejdsstilling og cramstatus for foreg?ende ?r */
>
> DATA c(sgio=3Dyes);
>
> =A0 =A0 =A0 =A0 =A0LENGTH tmaxprev statprev aar 3;
>
> =A0 =A0 =A0 =A0 =A0RETAIN tmaxprev 0;
>
> =A0 =A0 =A0 =A0 =A0RETAIN statprev 0;
>
> =A0 =A0 =A0 =A0 =A0RETAIN cramprev '0';
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 RETAIN selvstprev 0;
>
> =A0 =A0 =A0 =A0 =A0SET b;
>
> =A0 =A0 =A0 =A0 =A0tmaxprev =3D lag(tmax);
>
> =A0 =A0 =A0 =A0 =A0statprev =3D lag(status);
>
> =A0 =A0 =A0 =A0 =A0cramprev =3D lag(cram);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 selvstprev =3D lag(selvst);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF aar =3D 1985 THEN DO; =A0 =A0/* tilsta=
nd for 1984 s?ttes lig tilstand
> for 1985 */
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmaxprev=3Dtmax;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0statprev=3Dstatus;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cramprev=3Dcram;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 selvstpre=
v=3Dselvst;
>
> =A0 =A0 =A0 =A0 =A0END;
>
> RUN;

I agree with data _null_ that you need to think through your logical
processes. That said, there are also good tricks that can help. Look
at using a hash in SAS. Plenty of papers on how to do that. You can
also look at parallel processing but it depends on your task and
whether that is possible.

Also, while you could convert SAS code to something like C#, you may
not see any performance gains. I would not suggest you go down that
route w/o a lot of testing.

If you need consulting help, send me an email. I have helped other
companies deal with a similar issue in the past.

Alan
http://www.savian.net

0
Reply Savian 11/28/2009 9:32:55 PM

I agree with Alan - little tweeks are for insignificant issues. Your
boss is considering another language because he senses the real issue
is "program structure", and Base/SAS programmers very rarely use good
structured programming techniques.

You can easily "merge" three or more datasets with Objects written in
SCL.
I have done this with 30+ SAS and Oracle datasets.

This approach takes more code and more programming skill compared to
Base/SAS and Macro, but hey - how much time are you going to burn/
waste learning a new language? With SCL you have access to the full
set of Base/SAS and macro commands, plus a few hundred more.

I am covering this topic over on www.keystonesug.com in a series of
presentations "object programming".  Chapter #2 will be out on
December 9th and will cover Data Step replacement with Object code -
although this example will NOT be optimized for performance .

:o)





0
Reply montura 12/2/2009 12:25:22 PM

On Dec 2, 5:25=A0am, montura <montura...@gmail.com> wrote:
> I agree with Alan - little tweeks are for insignificant issues. Your
> boss is considering another language because he senses the real issue
> is "program structure", and Base/SAS programmers very rarely use good
> structured programming techniques.
>
> You can easily "merge" three or more datasets with Objects written in
> SCL.
> I have done this with 30+ SAS and Oracle datasets.
>
> This approach takes more code and more programming skill compared to
> Base/SAS and Macro, but hey - how much time are you going to burn/
> waste learning a new language? With SCL you have access to the full
> set of Base/SAS and macro commands, plus a few hundred more.
>
> I am covering this topic over onwww.keystonesug.comin a series of
> presentations "object programming". =A0Chapter #2 will be out on
> December 9th and will cover Data Step replacement with Object code -
> although this example will NOT be optimized for performance .
>
> :o)

SCL is a different language than Base SAS so you will have to learn it
as well. Plus it is not really growing. If someone was heading in that
direction from scratch, I would suggest learning C# before investing
any time in SCL. C# has a better editor, better support, 3rd party
support, etc.

If you are going to be doing loads of matrix work, an alternate
language may be faster than SAS. Similarly to relational database work
or strings. That said, most business problems mix and match issues and
SAS is a very good general purpose business language.

From my experience, if someone is out to displace SAS code it has
deeper issues (i.e. price) than performance. They just need to be
honest and not lay it out that SAS is slow.

What is the real intention of this manager?

Alan
0
Reply Savian 12/2/2009 4:37:29 PM
comp.soft-sys.sas 131474 articles. 30 followers. Post

4 Replies
461 Views

Similar Articles

[PageSpeed] 52


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Possible to convert SAS syntax code to SPSS code?
I had a user ask me this yesterday, and I don't know if there is a easy way to do this "conversion". They have been long, long time SAS users, but need to do some equivalent work in SPSS. Brute force would be difficult as some of their programs are long and sophisticated. Thanks, Necia A. Black, Ph.D. e-mail: black@buffalo.edu 246 Computing Center Web URL:http://www.acsu.buffalo.edu/~black SUNY-Buffalo FAX: (716) 645-3734 Buffalo, New York 14260 Ph...

Re: Possible to convert SAS syntax code to SPSS code?
necia <black@BUFFALO.EDU> wrote: > I had a user ask me this yesterday, and I don't know if there is a > easy way to do this "conversion". They have been long, long time SAS > users, but need to do some equivalent work in SPSS. Brute force would be > difficult as some of their programs are long and sophisticated. The easy way: grad students. :-) There is no automatic converter. A lot of features of the SAS data step just don't translate, anyway. A lot of the SQL and database management features don't translate directly, either. A lot of the macro ...

Converting SAS Code to Stata
Hello All, Is there a way to convert a SAS code into Stata? I have about 500 lines of SAS code that I would to convert into Stata. I appreciate any of your suggestions. My guess is that if you don't know both SAS and Stata, then you need to find someone that does, and they would attempt to rewrite the SAS code into Stata. I don't know of any automatic code generators to do this for you- you have to have a *person* to do this. SAS can save datasets that Stata can use- .dta files. -Mary --- okie_dude2003@YAHOO.COM wrote: From: Kris <okie_dude2003@YAHOO.COM>...

Converting SAS code to SQL
Is there a software or guide that could help me in converting SAS scoring code into SQL. Thanks, Sajeel Sajeel, As far as I know no there isn't. There is a book scheduale to be released soon I think on credit scoring. I doubt there ever will be as there are several methods and steps to build a scoring model. The last time I did this I used SQL to build the input and report data sets and used SAS stat to do the stats work. Toby Dunn From: sajeel manzoor <sajeelmanzoor@HOTMAIL.COM> Reply-To: sajeel manzoor <sajeelmanzoor@HOTMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject...

Include SAS code w/o including SAS code
All, Ok, I think this might be doable but I am drawing a blank. Suppose I have this code: %macro xyz; data temp.temp4; .do some sas stuff. run; %mend; Is there a way to write the macro statements out to a file? I can run them but I would also like to save them outside of SAS. Thanks, Alan Alan Churchill Savian <http://www.savian.net/> www.savian.net ...

Re: How to get the location of SAS code in the same SAS code thru
Hard to say what you mean with that! I start a interactive SAS session in Windows, then I include a SAS-program from "p:\myfiles\test.sas". In that program you want to know, that I included it from 'p:\myfiles\'? That is impossible! What are YOU doing? Perhaps you have a batch program on a mainframe which %INCLUDEs a source from a known location and does... The situation is somehow different then. You see, without knowing what you are doing, where you are and what you WANT to do, there is no chance to get it. Gerhard On Wed, 11 Apr 2007 07:43:50 -0700, Alok <alok.rus...

Re: Converting SAS code
Maybe, you could improve the performance of your SAS algorithms. Sometimes very simple changes make significant performance improvement. Doing so would seem easier than rewriting in a new language. Poorly optimized algorithms probable run about the same speed in any language. If you would tell the group about the overall process we could probably help you improve your existing SAS programs. The code snippet you supplied does not proved much information. On 11/28/09, Håkan Lane <hlane@cls.dk> wrote: > We have reached a point where our SAS code is taking enormou...

FW: Include SAS code w/o including SAS code
resending as I did not mean to send to just Andre ---------------------------------------- > From: donaldjhenderson@hotmail.com > To: wielki@ined.fr > Subject: RE: Include SAS code w/o including SAS code > Date: Tue, 12 Aug 2008 13:34:41 +0000 > > > Alan, > > If you want the generated SAS code try (untested): > > data _null_; > file "code.sas"; > length code $32000; > code = resolve('%xyz'); > put code; > run; > > You may want to format it (e.g., new line whenever you start a new statement). > > HTH, > donh &...

How to get the location of SAS code in the same SAS code thru a macro variable?
Hi all, I am facing a problem in which I need to get the location/path of a SAS code in a macro variable. I need to use the macro variable in the same SAS code. Is there any SAS option available which can do this for me? Or is there a code snippet which can achieve the same purpose? Can you please help me out as soon as possible since I need to deliver this tomorrow. Any help will be greatly appreciated. Thanks, Alok For Jobs run in BATCH you can use &SYSPROCESSNAME or something like %let pgmname=%sysfunc(getoption(sysin)); or for FILES submitted from Enhanced Editor in WINDOWS S...

Re: How to get the location of SAS code in the same SAS code thru #4
I use a macro from Frank DiIorio, CodeCrafters, Inc. that rely on SAS Dictionary Tables: %macro source_code/store; %global source_code; proc sql noprint; select XPath into :Source_Code separated by ' ' from dictionary.extfiles where fileref like "#LN00006" ; quit; %mend; The store is optional since I like to store compiled macros in a single location and call in with a mstored and sasmstore= options. I just add the following to my code to get a footnote indicating the full path and name of code submitted: %source_code; footnote1 "SOURCE CODE: &source_c...

Re: Include SAS code w/o including SAS code
I want the statements only, not the processing. Alan Alan Churchill Savian www.savian.net -----Original Message----- From: ./ ADD NAME=Data _null_, [mailto:iebupdte@gmail.com] Sent: Tuesday, August 12, 2008 6:20 AM To: Alan Churchill Cc: SAS-L@listserv.uga.edu Subject: Re: Include SAS code w/o including SAS code You need to provide more details. It is unclear to me if you want the statements generated by the macro MPRINT/MFILE written to the file or the MACRO definition FILE/PUT. Syntax MFILE | NOMFILE MFILE routes output produced by the MPRINT option to an external file. This is usef...

Re: Converting SAS code #3
In addition to what has already been said, I seen several items that suggest some tuning could help. I should add that I have not really looked at this with the care needed for careful analysis. First, you have a keep statement in a data step and I have to wonder whether there are many more variables that are brought from your original set that could be dropped in the Set statement. Next, you test on first.aar but you have ugenr in the BY statement. This is unnecessary in the BY statement. You set a length for the variable CRAM but it is not included in the Keep statement. You invoke optio...

Re: Converting SAS code #2
Håkan: I agree with Data _NULL_'s comment that you may likely get more cost-effective benefits by improving your algorithms in SAS rather than recoding in another language. For instance, in the code you provided, DATA A is generated as in intermediate input to DATA B, after which A is deleted; You might save resources by generating A as a view rather than as a dataset. And A is being generated with all values of PNR, even though when you merge it with other datasets, you filter on WHERE mod(pnr,10)=&pnrcif; So why put all the other values of PNR in A (whether as a view or a ...

Re: Converting SAS code to SQL
Sajeel, As far as I know no there isn't. There is a book scheduale to be released soon I think on credit scoring. I doubt there ever will be as there are several methods and steps to build a scoring model. The last time I did this I used SQL to build the input and report data sets and used SAS stat to do the stats work. Toby Dunn From: sajeel manzoor <sajeelmanzoor@HOTMAIL.COM> Reply-To: sajeel manzoor <sajeelmanzoor@HOTMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Converting SAS code to SQL Date: Mon, 5 Sep 2005 16:13:25 +0000 Is there a software or guide that could...

Re: How to get the location of SAS code in the same SAS code thru #3 685847
> From: Alok > I am facing a problem in which I need to get the > location/path of a SAS code in a macro variable. I need to > use the macro variable in the same SAS code. Is there any SAS > option available which can do this for me? Or is there a code > snippet which can achieve the same purpose? - - - MyMacro.sas - - - %macro MyMacro(path=); %*...; %Mend; - - - MyProgram.sas - - - %Let Path2MyMacro = c:\temp\MyMacro.sas; %Include "&Path2MyMacro."; %MyMacro(path = &Path2MyMacro.); Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov ...

Re: Include SAS code w/o including SAS code #6
Good Don. I should have remembered that trick from SGF. One minor issue, it doesn't preserve formatting. Other than doing the string split myself, any suggestions? Alan Alan Churchill Savian www.savian.net -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Don Henderson Sent: Tuesday, August 12, 2008 7:37 AM To: SAS-L@LISTSERV.UGA.EDU Subject: FW: Include SAS code w/o including SAS code resending as I did not mean to send to just Andre ---------------------------------------- > From: donaldjhenderson@hotmail.com > To: wielki@ined.fr ...

Re: Include SAS code w/o including SAS code #10
Summary: Macro generation of correct SAS code requires SAS execution. #iw-value=1 Alan, I do not see how this is possible. Consider: %macro q ( seed=0 ) ; %local cum ; data w ( keep = r ) ; do i = 1 to 20 ; r = ranuni ( &seed ) ; output ; end ; run ; data _null_ ; set w end = eof ; cum + r ; if eof then call symputx ( "cum" , cum ) ; run ; title1 "Cum = &cum" ; %mend q ; This macro ends up generating a TITLE statement. However, that title ...

Convert SAS code to S-Plus
This is the SAS code that i've got.. options pageno=1; %macro loglinear(likelihood,dataset,pstar,yvar,xvar); title2 "P* = &pstar"; %let p_max= &pstar; %let maxit=1000; %let crit=.0001; %let p=0; %do %while(%scan(&xvar,&p+1)^=); %let p=%eval(&p+1); %end; data x (keep=intercep &xvar); length intercep &xvar 8; set &dataset; intercep=1; run; data y ( keep = &yvar ); set &dataset; run; proc iml worksize=500000; reset nolog noprint; nbeta = &p + 1; beta=j(nbeta,1,0); sebeta=j(nbeta,1,0); rbeta=j(nbeta,1,0); rsebeta=j(nbeta,1,0); ...

Re: Include SAS code w/o including SAS code #5
you want to save the macro code in its own file access then depends on modifying one of the three uses of the word: SASautos Tutorials A SASautos Companion: Reusing Macros http://tinyurl.com/45nzzk for: http://www2.sas.com/proceedings/sugi30/267-30.pdf Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov > -----Original Message----- > From: Alan Churchill > Ok, I think this might be doable but I am drawing a blank. > Suppose I have this code: > %macro xyz; > data temp.temp4; > .do some sas stuff. > run; > %mend; > > Is there a way t...

Re: FW: Include SAS code w/o including SAS code
On Tue, 12 Aug 2008 13:36:52 +0000, Don Henderson <donaldjhenderson@HOTMAIL.COM> wrote: >resending as I did not mean to send to just Andre > >---------------------------------------- >> From: donaldjhenderson@hotmail.com >> To: wielki@ined.fr >> Subject: RE: Include SAS code w/o including SAS code >> Date: Tue, 12 Aug 2008 13:34:41 +0000 >> >> >> Alan, >> >> If you want the generated SAS code try (untested): >> >> data _null_; >> file "code.sas"; >> length code $32000; >> code = res...

Re: Include SAS code w/o including SAS code #2
Alan, not precisely clear what you are searching think thus also about this kind of program in addition to the mprint mfile answer of ~data _null_ HTH Andre libname malibmac "d:\temp"; options mstores sasmstore=malibmac; %macro foobar(aarg)/store source des='nothing or interresting'; %put arg=&arg; %mend; %copy foobar/source; Alan Churchill a �crit : > All, > > > > Ok, I think this might be doable but I am drawing a blank. > > > > Suppose I have this code: > > > > %macro xyz; > > data temp.temp4; > > .do some s...

Re: Include SAS code w/o including SAS code #7
I don't believe there is inconsistency in my statement. I don't want the log (run), just the statements. A macro is a macro so I can always run it if need be but the main gist is that I need the statements. I will just break the statements myself and do the formatting using Don's technique. Thanks for the help, Alan Alan Churchill Savian www.savian.net -----Original Message----- From: ./ ADD NAME=Data _null_, [mailto:iebupdte@gmail.com] Sent: Tuesday, August 12, 2008 9:05 AM To: Alan Churchill Cc: SAS-L@listserv.uga.edu Subject: Re: Include SAS code w/o including SAS code You...

Re: Include SAS code w/o including SAS code #4
I actually never want to store the macro code. I only want it available in a temp file which I then consume. For example: %macro xyz; data temp.temp4; ...do some sas stuff... run; %mend; I want to save the contents, formatted, into a text file (i.e. c:\temp\program.sas) which I can then consume in another application. I also want to execute the code. Hence: %xyz; Save the contents of the macro file to a text file with CRLF included. I don't want the run, merely the statements. Thoughts? Alan Alan Churchill Savian www.savian.net -----Original Message----- From: SAS(r) Disc...

Re: How to get the location of SAS code in the same SAS code thru #3 1561853
For Jobs run in BATCH you can use &SYSPROCESSNAME or something like %let pgmname=%sysfunc(getoption(sysin)); or for FILES submitted from Enhanced Editor in WINDOWS SAS/V9 you can use the following to access these two environment variables. %let FNAME = %sysget(SAS_EXECFILENAME); %let FPATH = %sysget(SAS_EXECFILEPATH); On 4/11/07, Alok <alok.rustagi@gmail.com> wrote: > Hi all, > > I am facing a problem in which I need to get the location/path of a > SAS code in a macro variable. I need to use the macro variable in the > same SAS code. Is there any SAS option avai...