2011-09-09 3 views
1

SPSS에서 가져온 열에 타임 스탬프가 있습니다. 예 : 'Observation'열의 7/6/2011 2:21SPSS의 DateTime에서 minuted를 뺄하는 방법

이것은 문자열 형식입니다. 이제는이 데이터에 대한 시간대 수정도 있습니다. 따라서 -60은이 날짜로부터 60 분을 뺍니다.

SPSS 구문에서 어떻게합니까?

답변

2

SPSS에는 기본 날짜 형식이 있지만 불행히도 게시 한 예를 포함하지는 않습니다. mm/dd/yyyyhh:mm 부분을 분리하여 대표적인 시간 형식으로 변환 한 다음 시간 계산을 수행하기 위해 문자열 필드의 시작 부분을 파싱합니다. 예

data list fixed/observation (A25). 
begin data 
7/6/2011 2:21 
10/11/2011 15:42 
07/06/2011 02:21 
3/15/2011 0:21 
end data. 

*getting the data part, assuming the space will always delimit the two parts. 
compute #space = char.index(observation," "). 
string date (A10). 
compute date = char.substr(observation,1,#space-1). 
*getting the time part. 
string time (A5). 
compute time = char.substr(observation,#space+1,5). 
execute. 

*now converting them into date formats. 
alter type date (A10 = ADATE10). 
alter type time (A5 = TIME5). 
*you should check these carefully to make sure they were converted correctly. 
*now making one time variable. 
compute date_time = date + time. 
formats date_time (DATETIME17). 
execute. 

*now it is just as simple as subtracting the specified value. 
compute date_time_adj = DATESUM(date_time,-60,"minutes"). 
execute. 
formats date_time_adj (DATETIME17). 
들어

관련 문제