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 (March 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 30 Mar 2004 17:55:40 -0500
Reply-To:     "Ross, Michael D" <michael.ross@ASTRAZENECA.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Ross, Michael D" <michael.ross@ASTRAZENECA.COM>
Subject:      Re: &sysparm Question?
Content-Type: text/plain; charset="iso-8859-1"

Thanks. How does its value get assigned?

-----Original Message----- From: SAS Bigot [mailto:SAS_Bigot@ml1.net] Sent: Tuesday, March 30, 2004 5:40 PM To: Ross, Michael D; SAS-L@LISTSERV.UGA.EDU Subject: RE: &sysparm Question?

Yes, it is automatic macro variable.

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ross, Michael D Sent: Tuesday, March 30, 2004 5:30 PM To: SAS-L@LISTSERV.UGA.EDU Subject: &sysparm Question?

Hello, Is &sysparm a system variable?

libname local "%SCAN(&sysparm,1,~)"; %syslput(trial, %SCAN(&sysparm,2,~));

Thanks. Mike

-----Original Message----- From: SAS Bigot [mailto:SAS_Bigot@ML1.NET] Sent: Tuesday, March 30, 2004 5:20 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Alternative methods to create a month variable

Glenn,

Don't complicate it so much. Why embed another function when you don't need to? The intnx function is not necessary to produce the correct result. The statements below do the same thing.

trans_mo = put(intnx('month', input(trans_dt, yymmdd6.), 0), yymmn6.); trans_mo = put(input(trans_dt, yymmdd6.), yymmn6.);

I also question the need to create the other variable, trans_mo_sas. Any date calculations or manipulations can be handled with trans_dt_sas.

I work for a large financial services company and working with data sets with 10+ million obs is fairly common, so I guess I try to be a minimalist when it comes to coding and variable creation.

Lu,

If you have any influence over the creation of the transaction data set, you should have the trans_dt created as a SAS date variable. It could make life much easier in the future when using that element.

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Glenn Heagerty Sent: Tuesday, March 30, 2004 11:23 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Alternative methods to create a month variable

Hello Lu Liu,

You can replace all of your IF/THEN/ELSE statements with this single line:

trans_mo = put(intnx('month', input(trans_dt, yymmdd6.), 0), yymmn6.);

The input function takes the trans_dt value and creates a SAS date value. The intnx function returns the SAS date value corresponding to the first date of the month containing trans_dt. The put function takes the SAS date value of the first day of the month and converts it to your format for trans_mo.

You might want to keep your trans_dt as a SAS date value and use the various SAS date formats for procedural output or other processing. I would also recommend keeping trans_mo as a SAS date value if you have to perform additional tests. You can do this like:

trans_dt_sas = input(trans_dt, yymmdd6.); trans_mo_sas = intnx('month', trans_dt_sas, 0);

Hope this helps,

Glenn

Lu Liu wrote: > Hi, > > I am creating a transaction month variable (TRANS_MO) from transaction date > (TRANS_DT). Please note both variables are not in DATE but STRING format. > Since there are 1 1/2 years data, I need to do the IF/ELSE IF statement 18 > times. I just wonder whether there is a better way to code this. > > > DATA ALLTRANS; > SET ALLTRANS; > LENGTH TRANS_MO $6; > IF TRANS_DT >= '021001' AND TRANS_DT <= '021031' > THEN TRANS_MO = '200210'; > ELSE IF TRANS_DT >= '021101' AND TRANS_DT <= '021130' > THEN TRANS_MO = '200211'; > ELSE IF TRANS_DT >= '021201' AND TRANS_DT <= '021231' > THEN TRANS_MO = '200212'; > ELSE IF TRANS_DT >= '030101' AND TRANS_DT <= '030131' > THEN TRANS_MO = '200301'; > ELSE IF TRANS_DT >= '030201' AND TRANS_DT <= '030228' > THEN TRANS_MO = '200302'; > ELSE IF TRANS_DT >= '030301' AND TRANS_DT <= '030331' > THEN TRANS_MO = '200303'; > ELSE IF TRANS_DT >= '030401' AND TRANS_DT <= '030430' > THEN TRANS_MO = '200304'; > > (and more till TRANS_MO = '200403') > > Thank you very much for your suggestions. > > Lu >


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