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 131019 articles. 27 followers. Post

4 Replies
401 Views

Similar Articles

[PageSpeed] 16


  • 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...

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...

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...

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); ...

Converting SAS code to SPSS script
Hi folks Does anyone know a way (short of employing a consultant) to convert SAS code to SPSS (11.5) script? I have 3000 lines of SAS script that does some fuzzy matching. Converting it manually is taking too long because the program is very involved and the files I'm trying to match are 2.6m records each so it's not a small job. Is there a feature of SPSS / SAS or a download that will convert from SAS to SPSS? Cheers Rob ...

Convert SAS code into SPSS syntax
Hey guys, I am new to SPSS macro. Now I have some SAS code and try to convert them to SPSS syntax.It is really an emergency. Could anybody help me out? The SAS code are as follows: 1. %let a=10; data new; set old; where b=%eval(&a-1); run; 2. %macro byweek(a, b); proc summary data=&a.week; by system cat name; var absent enrolled; output out=&b._out sum=&b._absent &b._enrolled; run; data &b._out2; set &b._outs; &b._rate=(&b._absent*100)/&b._enrolled; keep system cat name &b._absent &b._enrolled &b...

Re: Converting SAS Code to Stata 13017
> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Joe > Matise > Sent: Monday, December 07, 2009 2:18 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Converting SAS Code to Stata > > Probably outside of my expertise then [I'm a data person, not a stat > person], but you certainly could run that in batch: > * Construct dataset with your model information, so, 100 rows [or > whatever] > and the appropriate variables that differentiate each run > * Use CALL EXECUTE to run a macro that has your ...

Re: Converting SAS Code to Stata 131944
I have a pretty good understanding of Base SAS and SAS macros, but I have never used Stata. The only reason why I am compelled to use Stata (which is located on a server) is that for the SAS program that I have written and the data that needs to be processed, my PC would not work or in other words the processing speed will not be good enough. It seems that there is no easy way to convert a SAS program to Stata. Thanks!! ...

Re: Converting SAS Code to Stata 280829
Could you run it in batch overnight? Or is this something that would take a week to run? I can't imagine STATA would be much if any faster than SAS except for the server's speed, so perhaps something like this could be attempted? How much data are you processing [events/rows/etc.]? What sort of desktop time are you currently using to run it? In any event, you might try posting your code and what it's supposed to do; on the list we often find that it's possible to significantly speed up code by making a few fairly common modifications. 500 lines isn't much, so ...

Convert SAS code to S-Plus #2
I have no idea of SAS and just a little of S-Plus!Does anyone know how i can convert a code that i've got in SAS into an S-Plus or Matlab code???? HELP!!!! ...

Help in SAS code- convert to .sav file
Hi, Is there any SAS code for converting a SAS data set to a SPSS (.sav) file. I did work by using the SPSS commands 'get sas data' but I wanted to know whether there is any method to convert the dataset into .sav file without using SPSS (using SAS codes). -Premalatha __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Sorry, I know of plenty of ways to get SPSS data into SAS, but once I have= =20 my data in SAS I have never bothered to wonder how to get it into SPSS.=20 <Uh-oh, ...

SAS code to convert all text fields to Upcase
Hi, I need help to have a SAS macro that can convert all texts in all character fields in a dataset into upcase. The code can identify the character fields in the dataset, and then convert the texts in these fields into upcase. Thanks for your help Frank Frank, Here's one solution....note this does NOT upcase formatted variables proc contents data=libname.ds_name out=work.contents(keep=name type varnum) noprint; run; proc sort data=work.contents; by varnum; run; data _null_; set work.contents end=eof; where type = 2; /* 1 - num, 2 - char */ call symput('v'||trim(l...

Re: Converting SAS code to SQL #2
Sajeel: As we have seen earlier on SAS-L, the term 'scoring' has many different meanings in statistics and computing. The SQL CASE ...WHEN ... THEN ... ELSE ... clause in a SELECT statement is analogous to IF ... THEN ... or SELECT ... statements in Data step programs. The SQL SELECT list can contain complex arithmetic expressions and functions [ SELECT (X1*b1 + X2*b2 + ...) AS estimate FROM .... ]. If you are asking how to use summary functions in SQL, take a look at GROUP BY ... HAVING ... clauses. For anything else, you'll have to provide more detail on what you are trying to do...

Re: Converting SAS code to SQL #3
sajeelmanzoor@HOTMAIL.COM wrote: >Is there a software or guide that could help me in converting SAS scoring >code into SQL. I don't know whether you're talking about building a scorecard, or scoring data after creating a predictive model in one of the SAS statistical procs. If your goal is to convert SAS code for *building* a scorecard or computing a predictive model into SQL, then forget it. You might as well ask to convert Adobe Photoshop into SQL. If your goal is to take a previously-built scorecard and use SQL to apply it, then you shouldn't have a problem. You can c...

Re: Converting SAS Code to Stata #5
Probably outside of my expertise then [I'm a data person, not a stat person], but you certainly could run that in batch: * Construct dataset with your model information, so, 100 rows [or whatever] and the appropriate variables that differentiate each run * Use CALL EXECUTE to run a macro that has your parameters as macro parameters That could run overnight and produce all of your results, and then in the morning you can do whatever you need to do to the results to make them useful. It's quite possible that there are better ways to do this [and it might be worth posting the specifics,...

convert sql server code subquerey to sas
I have a hard time to convert tsql subquery to sas Part of tsql select ----- SelectionDate = (select convert(varchar, pc.SelectionDate, 101) where pc.selectiondate > '01/01/1900'), ConAssignedDate = (select top 1 convert(varchar, attributevalue, 101) frompxad where pxad.prospectcaseid = a.prospectcaseid and attributeid = 223), ReferralDate = (select convert(varchar, pc.referraldate, 101) where pc.referraldate > '01/01/1900' and a.workflowstatus in (370,400,450,500,650)), OpenedDate = (select convert(varchar, pc.OpenedDate, 101) where pc.OpenedDate > '01/01/1...

Re: Converting SAS Code to Stata #2 131946
On Mon, 7 Dec 2009 15:14:22 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote: >Could you run it in batch overnight? Or is this something that would take a >week to run? I can't imagine STATA would be much if any faster than SAS >except for the server's speed, so perhaps something like this could be >attempted? How much data are you processing [events/rows/etc.]? What sort >of desktop time are you currently using to run it? > >In any event, you might try posting your code and what it's supposed to do; >on the list we often find that it's...

Re: Converting SAS Code to Stata #3 131948
On Mon, 7 Dec 2009 16:18:12 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote: >Probably outside of my expertise then [I'm a data person, not a stat >person], but you certainly could run that in batch: >* Construct dataset with your model information, so, 100 rows [or whatever] >and the appropriate variables that differentiate each run >* Use CALL EXECUTE to run a macro that has your parameters as macro >parameters > >That could run overnight and produce all of your results, and then in the >morning you can do whatever you need to do to the results t...

Re: Converting SAS Code to Stata #3 1617295
You don't say what type of SAS code you have. Is using PMML an option for you? Philip Rack MineQuest, LLC SAS & WPS Consulting and WPS Reseller Tel: (614) 457-3714 Web: www.MineQuest.com Blog: www.MineQuest.com/WordPress -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kris Sent: Monday, December 07, 2009 3:01 PM To: SAS-L@LISTSERV.UGA.EDU Subject: 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 app...