= SPSS System Variables = '''System variables''' track the current state of the interpretter. The dollar sign (`$`) is a disallowed leading character for user-defined variables because this is reserved for system variables. <> ---- == CaseNum == `$CASENUM` holds the current case's row number. To create an 8-digit unique identifier number, try: {{{ compute UniqueID = 10000000 + $casenum. }}} ---- == Date == `$DATE` holds the current date. Use `$TIME` instead of this. ---- == Time == `$TIME` holds the current date and time as the number of seconds from October 14, 1582, to the execution time of a command accessing it. This can be used to construct a timestamp. {{{ data list free / a. begin data. 1 end data. dataset name TIMESTAMP. execute. string timestamp (A20). compute #time = $time. compute timestamp=concat( char.substr(string(xdate.year(#time),N4),3,2), string(xdate.month(#time),N2), string(xdate.mday(#time),N2), "_", string(xdate.hour(#time),N2), string(xdate.minute(#time),N2), ). execute. do if $casenum=1. write outfile 'timestamp.sps' /1 "define !timestamp() " timestamp " !enddefine.". end if. dataset close TIMESTAMP. execute. insert file='timestamp.sps'. execute. erase file='timestamp.sps'. }}} `!timestamp()` can now be used to reference the current date and time. ---- CategoryRicottone