OMS and current timestamp

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

OMS and current timestamp

Piotr Kołodziejczyk-2
Dear All!

I'd like to use OMS to create tables export. 
I use:
OMS
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE='D:\temp\oms_temp.xls').

But instead of 'oms_temp.xls' I'd like to have current timestamp f.e.:
'oms_temp_20121231_1818.xls'

I tried with $time, define-!enddefine macros, but it still doesn't work:

define !oms (v=!CMDEND)
OMS
!let !s=$time
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE=!quote(!Concat('D:\temp\oms_temp_',!s,'.xls')).
!enddefine.

Is it possible to use current data in syntax?


Best regards,
Piotr


Reply | Threaded
Open this post in threaded view
|

Re: OMS and current timestamp

David Marso
Administrator
"Is it possible to use current data in syntax?"
NOPE!!! MACRO is a brain dead string parser and knows NOTHING about data values.
You will need to use Basic Scripting (Now) or python (???).
The neo-pythonista gang will surely goad you towards python.
Rock On.  
---
Piotr Kołodziejczyk-2 wrote
Dear All!

I'd like to use OMS to create tables export.
I use:
OMS
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE='D:\temp\oms_temp.xls').

But instead of 'oms_temp.xls' I'd like to have current timestamp f.e.:
'oms_temp_20121231_1818.xls'

I tried with $time, define-!enddefine macros, but it still doesn't work:

define !oms (v=!CMDEND)
OMS
!let !s=$time
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE=!quote(!Concat('D:\temp\oms_temp_',!s,'.xls')).
!enddefine.

Is it possible to use current data in syntax?


Best regards,
Piotr
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: OMS and current timestamp

Jon K Peck
In reply to this post by Piotr Kołodziejczyk-2
Here's a simple way to do this with programmability.

begin program.
import time
filespec = r"c:/temp/oms_temp_" + time.asctime() + ".xls"
spss.Submit( r"""OMS /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE="%s".""" % filespec)
end program.

It is possible to customize the date/time format further if needed.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Piotr Kołodziejczyk <[hidden email]>
To:        [hidden email],
Date:        01/17/2013 10:06 AM
Subject:        [SPSSX-L] OMS and current timestamp
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear All!

I'd like to use OMS to create tables export. 
I use:
OMS
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE='D:\temp\oms_temp.xls').

But instead of 'oms_temp.xls' I'd like to have current timestamp f.e.:
'oms_temp_20121231_1818.xls'

I tried with $time, define-!enddefine macros, but it still doesn't work:

define !oms (v=!CMDEND)
OMS
!let !s=$time
  /SELECT TABLES
  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
  /DESTINATION FORMAT=XLS
   OUTFILE=!quote(!Concat('D:\temp\oms_temp_',!s,'.xls')).
!enddefine.

Is it possible to use current data in syntax?


Best regards,
Piotr


Reply | Threaded
Open this post in threaded view
|

Re: OMS and current timestamp

kwame woei
In reply to this post by David Marso
The syntax is untested, but the concept is: write an outfile with the macro text and a single variable containg a single case . Run the outfile in the syntax thus effectively loading the macro in the memory. Then call the timestamp macro loading the OMS.

I use timestamps in combination with Excel OMS myself. You may have to fiddle around a bit, but the below works or will work.


string year (a4).
compute year = string(xdate.year($time)).
execute.

write outfile 'c:\test\macro.sps'
"define !year ()"'year'" !enddefine."
execute.

insert file = 'c:\test\macro.sps'.

define !timestamp ()
!concat('outfile=', !quote(!concat('d:\temp\', !eval(!year), '.xls')))
!enddefine.

OMS
 /SELECT TABLES
 /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
 /DESTINATION FORMAT=XLS
  !timestamp

Op 17 jan. 2013 om 18:17 heeft "David Marso" <[hidden email]> het volgende geschreven:

> "Is it possible to use current data in syntax?"
> NOPE!!! MACRO is a brain dead string parser and knows NOTHING about data
> values.
> You will need to use Basic Scripting (Now) or python (???).
> The neo-pythonista gang will surely goad you towards python.
> Rock On.
> ---
>
> Piotr Kołodziejczyk-2 wrote
>> Dear All!
>>
>> I'd like to use OMS to create tables export.
>> I use:
>> OMS
>>  /SELECT TABLES
>>  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
>>  /DESTINATION FORMAT=XLS
>>   OUTFILE='D:\temp\oms_temp.xls').
>>
>> But instead of 'oms_temp.xls' I'd like to have current timestamp f.e.:
>> 'oms_temp_20121231_1818.xls'
>>
>> I tried with $time, define-!enddefine macros, but it still doesn't work:
>>
>> define !oms (v=!CMDEND)
>> OMS
>> !let !s=$time
>>  /SELECT TABLES
>>  /IF COMMANDS=['CTables'] SUBTYPES=['Custom Table']
>>  /DESTINATION FORMAT=XLS
>>   OUTFILE=!quote(!Concat('D:\temp\oms_temp_',!s,'.xls')).
>> !enddefine.
>>
>> Is it possible to use current data in syntax?
>>
>>
>> Best regards,
>> Piotr
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to email me.
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/OMS-and-current-timestamp-tp5717453p5717455.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: OMS and current timestamp

Albert-Jan Roskam
> string year (a4).

> compute year = string(xdate.year($time)).
> execute.
>
> write outfile 'c:\test\macro.sps'
> "define !year ()"'year'" !enddefine."
> execute.
>
> insert file = 'c:\test\macro.sps'.
>
> define !timestamp ()
> !concat('outfile=', !quote(!concat('d:\temp\',
> !eval(!year), '.xls')))
> !enddefine.


BEGIN PROGRAM.
import time, spss
spss.SetMacroValue("!time", time.strftime("%Y-%m-%d %H:%M:%S"))
END PROGRAM.

OMS
....

!time.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD