|
This syntax:
COMPUTE stringvar= NUMBER (newvar,F9.0). Give me a numeric variable with format 8.2 no matter what. I can't figure out why? Thanks. Mark ===================== 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 |
|
The default display format for new numeric variables is F8.2. The format argument of the Number function does not set the format of the new numeric variable; it specifies the numeric format for interpreting the string value. The purpose of the format argument might be more apparent with a somewhat less standard "numeric" value, such as a date. Consider the following:
data list free /stringdate (a11). begin data 29-Oct-2007 end data. *convert the string to a number, based on interpreting the string as a date. compute datevar=number(stringdate, date11). list. formats datevar (date11). list. You can declare the new numeric variable with a format prior to the Compute command with the Numeric command, or you can define the format after creating the variable with the Formats command. ________________________________ From: SPSSX(r) Discussion on behalf of Mark Palmberg Sent: Fri 4/11/2008 8:51 PM To: [hidden email] Subject: string var to numeric var with compute This syntax: COMPUTE stringvar= NUMBER (newvar,F9.0). Give me a numeric variable with format 8.2 no matter what. I can't figure out why? Thanks. Mark ===================== 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 |
|
Hi,
Before I used Dynamic Device Exchange using SAS to pass X4ML commands to Excel*). Although getting the code right could be quite cumbersome, it's really handy once it's working. It allows the user to carry out procedures in Excel (for instance, a user-specified format for (CI95_low - CI95_up), but even VBA macros prefdefined in Excel can be called). Would something like this possible using SPSS/Python in conjunction with MS Excel? I don't want to use Sax Basic scripts, because of the 'asynchrony problem'. Cheers!! Albert-Jan *) see e.g.: http://www.sas-consultant.com/professional/SUGI26-Against-All-ODS-1.pdf __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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 |
|
The Windows DDE technology has always been a bit fragile, so I have avoided it wherever possible. VBA and COM are much preferable in my experience.
You can, of course, use SaxBasic to do COM calls to another app. Prior to SPSS 16, however, invoking a SaxBasic script with the SCRIPT command resulted in asynchronous execution. That may or may not matter if you are driving another application. You can alternatively access the COM calls from a Python program if you have installed the win32com Python extensions. That will run synchronously and gives access to the same COM methods. Here is a short Python program that I happen to have lying around that manipulates Excel from within SPSS (or outside it) just to give you an idea of how you might use this. BEGIN PROGRAM. #move sheet to new workbook import win32com.client filespec = r"c:\temp\myoutput.xls" fromfilespec = r"c:\temp\datesi18n.xls" wblist = [filespec, fromfilespec] e = win32com.client.Dispatch("Excel.Application") e.DisplayAlerts = False e.Workbooks.Add() for w in wblist: wb = e.Workbooks.Open(w) wb.Sheets[0].Move(Before = e.Workbooks[0].Sheets[0]) if e.Workbooks.Count > 1: wb.Close() print e.Workbooks[0].Sheets.Count END PROGRAM. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam Sent: Saturday, April 12, 2008 2:50 AM To: [hidden email] Subject: [SPSSX-L] DDE session between spss and excel? Hi, Before I used Dynamic Device Exchange using SAS to pass X4ML commands to Excel*). Although getting the code right could be quite cumbersome, it's really handy once it's working. It allows the user to carry out procedures in Excel (for instance, a user-specified format for (CI95_low - CI95_up), but even VBA macros prefdefined in Excel can be called). Would something like this possible using SPSS/Python in conjunction with MS Excel? I don't want to use Sax Basic scripts, because of the 'asynchrony problem'. Cheers!! Albert-Jan *) see e.g.: http://www.sas-consultant.com/professional/SUGI26-Against-All-ODS-1.pdf __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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 |
| Free forum by Nabble | Edit this page |
