Liebe Community,
ich kaue seit geraumer Zeit auf einem Problemchen, das vermutlich extrem einfach ist... *grrrr*
Wie kann ich ein Datum über Syntax eingeben? (Also quasi das Datums-Pendant zu compute [Variable] = [Wert]. exe.)
Die Variable hat das Format edate10.
Für's Hirn-Erlösen dankt vorab,
Maria
Datum über Syntax eintragen
-
- Beiträge: 2391
- Registriert: 06.02.2011, 19:58
-
- Beiträge: 2391
- Registriert: 06.02.2011, 19:58
RE
Hier sind Beispiele von Raynalds:
*http://www.spsstools.net/LearningSyntax ... teTutorial
* 1. Create a date variable from a numeric variable such as 19901204.
DATA LIST LIST /date1.
BEGIN DATA
19901204
20000131
END DATA.
LIST.
COMPUTE day1=MOD(date1,100).
COMPUTE month1=MOD(TRUNC(date1/100),100).
COMPUTE year1=TRUNC(date1/10000).
COMPUTE date2=DATE.DMY(day1,month1,year1).
FORMATS date2(SDATE10).
VARIABLE WIDTH date2(11).
EXECUTE.
* 2. Create a date variable from 3 numeric variables containing day, month and year.
DATA LIST LIST /year1 month1 day1.
BEGIN DATA
1999 12 07
2000 10 18
2000 07 10
2001 02 02
END DATA.
LIST.
COMPUTE mydate=DATE.DMY(day1,month1,year1).
FORMATS mydate(DATE11).
VARIABLE WIDTH mydate(11).
EXECUTE.
* Using an other date format.
COMPUTE mydate2=mydate.
FORMATS mydate2(ADATE11).
VARIABLE WIDTH mydate2(11).
EXECUTE.
* 3. Convert a string containing a date into a date variable.
DATA LIST LIST /datestr(A10).
BEGIN DATA
11/26/1966
01/15/1981
END DATA.
LIST.
*http://www.spsstools.net/LearningSyntax ... teTutorial
* 1. Create a date variable from a numeric variable such as 19901204.
DATA LIST LIST /date1.
BEGIN DATA
19901204
20000131
END DATA.
LIST.
COMPUTE day1=MOD(date1,100).
COMPUTE month1=MOD(TRUNC(date1/100),100).
COMPUTE year1=TRUNC(date1/10000).
COMPUTE date2=DATE.DMY(day1,month1,year1).
FORMATS date2(SDATE10).
VARIABLE WIDTH date2(11).
EXECUTE.
* 2. Create a date variable from 3 numeric variables containing day, month and year.
DATA LIST LIST /year1 month1 day1.
BEGIN DATA
1999 12 07
2000 10 18
2000 07 10
2001 02 02
END DATA.
LIST.
COMPUTE mydate=DATE.DMY(day1,month1,year1).
FORMATS mydate(DATE11).
VARIABLE WIDTH mydate(11).
EXECUTE.
* Using an other date format.
COMPUTE mydate2=mydate.
FORMATS mydate2(ADATE11).
VARIABLE WIDTH mydate2(11).
EXECUTE.
* 3. Convert a string containing a date into a date variable.
DATA LIST LIST /datestr(A10).
BEGIN DATA
11/26/1966
01/15/1981
END DATA.
LIST.
drfg2008