全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SPSS论坛
1312 1
2014-05-06
        I have data from an experiment that is sampling responses between 59 to 60 hz. There is no way to predict the drop-down in sampling rate throughout the experiment which runs for 18 minutes.

Each of the sampled responses are numbered from 1 to N (for total number of rows) showing relative passage of time, stored in variable 'frame'. I also have a unix time stamp marking absolute time stored in 'unixtime'. But unixtime is reported in whole integers & not in fractional units. For example:

1376925380 may be repeated 59 times;
1376925381 may be repeated 60 times in the data file.
I would like to create a new variable that tracks each consecutive frame (or sampled response) from 1 to 60 or from 1 to 59, as the case may be, for each given unixtime stamp in SPSS. See the desired re-arrangement below. Any help w/ appropriate SPSS-syntax is appreciated!

unixtime    newframe
1376925380  1
1376925380  2
1376925380  3
1376925380  4
1376925380  5   
1376925380  6
....
1376925380  58
1376925380  59
1376925381  1
1376925381  2
1376925381  3
1376925381  4
....        ....
1376925381  60
1376925382  1
1376925382  2
....

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-5-6 01:33:57
*fake data.
set seed 10.
input program.
loop #i =  1 to 100.
  loop #j = 1 to TRUNC(RV.UNIFORM(59,61)).
    compute unixtime = 1376925379 + #i.
    end case.
  end loop.
end loop.
end file.
end input program.

*Using lag to calculate newframe variable.
DO IF ($casenum = 1) OR (unixtime <> lag(unixtime)).
  compute newframe = 1.
ELSE.
  compute newframe = lag(newframe) + 1.
END IF.
exe.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群