| Date: | Wed, 31 Oct 2001 09:17:54 -0500 |
| Reply-To: | Michael Wexler <Michael.Wexler@E-DIALOG.COM> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Michael Wexler <Michael.Wexler@E-DIALOG.COM> |
| Subject: | Re: IN SUPPORT OF SIMPLER SYNTAX |
|
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
Diane makes a fair point, but her concerns hide the underlying issue.
What is really missing is commented, documented explanation of why the
"clever" syntax is necessary, and how it works.
For many of the problems here, the "clever" syntax is the ONLY solution
which can work without incredible effort. I find that once I understand
what is being achieved, my own code gets better, faster, and easier to work
with as a result.
So, its easy to say, as a reader, "I don't have time to step through and
understand the code here". And its easy to say, as a writer, "I am giving a
free service, who has time to document?" But if we as writers give a touch
of commented documentation of the point of the code, and we as readers take
a moment to see what's really being done, we all benefit.
For example, the code below:
COMPUTE date = DATE.MDY(number(substr(txtdate,5,2),f2.0),
number(substr(txtdate,7,2),f2.0),
number(substr(txtdate,1,4),f4.0)) .
FORMATS date (ADATE10).
Can be easily explained as: "Given the date in the YYYYMMDD format, we
import as a string and then parse out (separate) the year, month, and date
components by their location in the string. We know, for example, that the
month will always be at the 5th character and is 2 characters long. The
Date.MDY function will put the pieces together into a proper SPSS date/time
variable, once we convert them from characters to numbers with the Number
function."
So, please continue with the "clever" code. I have learned tons, and I
don't want people to think that the "simpler" syntax is better... because
while parsimony is great, and Ockham's razor is sharp, sometimes a touch of
cleverness makes things much more effective.
Just one person's opinion,
Michael
Michael Wexler
Director of Research, E-Dialog
131 Hartwell Ave. Lexington, MA 02421
781-372-3376 (v)
781-863-8118 (f)
mwexler@e-dialog.com
> -----Original Message-----
> From: Cohen,Diane [mailto:dc42@EXCHANGE1.DREXEL.EDU]
> Sent: Wednesday, October 31, 2001 8:55 AM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: IN SUPPORT OF SIMPLER SYNTAX
>
>
> Questions are frequently posed for which I would like
> answers. I used to save the replies, even tho I might not
> have an immediate need for them. I stopped doing this
> because often responders pose such complex solutions that I
> now simply delete their emails without even opening, because
> from experience I know them to be unusable. It really does a
> disservice to many on this list to demonstrate one's skill at
> the expense of others who could, and want to learn. This is a
> challenge and plea to have responders take a stab at making
> solutions as simple, not as complex as possible in the
> future. Another Diane
>
>
> -----Original Message-----
> From: Hank Daley [mailto:hdaley@DMHMRSAS.STATE.VA.US]
> Sent: Wednesday, October 31, 2001 8:42 AM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: Re: converting dates
>
>
> I can name that tune in two commands.
>
> COMPUTE date =
> DATE.MDY(number(substr(txtdate,5,2),f2.0),number(substr(txtdat
e,7,2),f2.0),n
> umber(substr(txtdate,1,4),f4.0)) .
> FORMATS date (ADATE10).
>
> Sometimes I think it is easier for questioners to see syntax
> in simpler
> forms before they attempt to develop more parsimonious syntax.
>
> Cheers Dianne.
>
> -----Original Message-----
> From: Hosking, Dianne [mailto:Dianne.Hosking@ACT.GOV.AU]
> Sent: Tuesday, October 30, 2001 8:51 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: Re: converting dates
>
>
> an alternate:
> NUMERIC ndate (f10.0).
> FORMATS ndate (EDATE10).
> compute ndate=DATE.DMY(SUBSTR(txtdate,7,2),substr(txtdate,5,2),
> substr(txtdate,1,4)).
> EXECUTE.
>
> Now aint that a nice neat and concise bit of code?
> ROFLMAO.
> Dianne Hosking
> Data Project Officer
> Data Management Unit
> Health Information Service
> ACT Department of Health, Housing and Community Care
> Telephone: 02 6207 5405
>
>
>
> : -----Original Message-----
> : From: Hank Daley [mailto:hdaley@DMHMRSAS.STATE.VA.US]
> : Sent: Wednesday, 31 October 2001 5:18
> : To: SPSSX-L@LISTSERV.UGA.EDU
> : Subject: Re: converting dates
> :
> :
> : string year (a4).
> : string month (a2).
> : string date (a2).
> :
> : compute year=substr(oldvar,1,4).
> : compute month=substr(oldvar,5,2).
> : compute date=substr(oldvar,7,2).
> : exe.
> :
> : recode year (convert) into year1.
> : recode month (convert) into month1.
> : recode date (convert) into date1.
> :
> : formats year1 (f4.0).
> : formats month1 (f2.0).
> : formats date1 (f2.0).
> : exe.
> :
> : compute datevar=date.dmy(date1,month1,year1).
> : formats datevar (adate10).
> : exe.
> :
> : -----Original Message-----
> : From: Marks, Jim [mailto:jim.marks@LODGENET.COM]
> : Sent: Tuesday, October 30, 2001 12:02 PM
> : To: SPSSX-L@LISTSERV.UGA.EDU
> : Subject: converting dates
> :
> :
> : I have a text file with dates in the following format:
> :
> : YYYYMMDD
> :
> : I can import this as a number, but I would like to convert it
> : to an actual
> : date.
> :
> : Any suggestions would be greatly appreciated.
> :
> : TIA
> :
> : Jim Marks
> : Market Analyst
> : LodgeNet Entertainment Corporation
> : 605.988.1616
> :
>
|