Subscribe Bookmark RSS Feed

script for grabing particular elements from a survival analysis and outputing them to a single MS word

chang

Community Trekker

Joined:

Jul 11, 2012

Hi,

I am intended to grab particular elements from a survival analysis and export these to a single MS word. The following analysis is based on a single data table  "qryAFF14." There are three treatment groups, selected in the WHERE clause, of my interest. I'd like to make a failure plot for the 3 groups and two pair comparisons (acetone vs nil, acetone vs methoprene) and get their estimates. My codes below have produced what I need. My data table is attached. Thanks. My questions:


How do I output these three elements to a MS word?

Could the WHERE clauses be simplified to one as in SAS "where treatment in ('acetone', 'nil')?

//part 1: get data into a data table

dbq_string = "DBQ=E:\Now\(Project) RFID_r3_Homing_r1\Ben analysis\Chang_bee_db.mdb;" ||

             "DefaultDir=E:\Now\(Project) RFID_r3_Homing_r1\Ben analysis;" ||

             "Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;" ||

             "FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\chang_bee_db.dsn;" ||

             "MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;";

dt1=Open Database(dbq_string, "SELECT * FROM qryAFF14", "qryAFF14", invisible);

//part 2: failure plot with 3 groups

dt=data table ("qryAFF14", invisible);

dt<< Survival(

    Y( :AFF14 ),

    Grouping( :treatment ),

    Failure Plot( 1 ),

    Survival Plot( 0 ),Where( :treatment == "acetone 5µl" | : treatment== "nil" | :treatment == "methoprene 5µll (40 µg/µl)" ),

    SendToReport(

        Dispatch(

            {"Failure Plot"},

            "Failing",

            TextEditBox,

            {Set Text( "Cumulative rate of initiating the first experience" )}

        ),

        Dispatch(

            {"Failure Plot"},

            "AFF14",

            TextEditBox,

            {Set Text( "Age (day)" )}

        )

    )

)

// part 3: get estimate and comparison between acetone and nil

<< Survival(

    Y( :AFF14 ),

    Grouping( :treatment ),

    Failure Plot( 0 ),

    survival plot(0),

    ,Where( :treatment == "acetone 5µl" | :treatment == "nil" ),

)

// part 4: get estimate and comparison between acetone and methoprene

<<Survival(

    Y( :AFF14 ),

    Grouping( :treatment ),

    Failure Plot( 0 ),

    survival plot(0),

    ,Where( :treatment == "acetone 5µl" | :treatment == "methoprene 5µll (40 µg/µl)" ),

);

close (dt); /*close datatable the following codes doesn't refer to the wrong dt*/

// part 5: output selected elements from part2, 3, 4 to a MS word

??

3 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

JMP sort of has an IN list.  This construct is very handy and will do what you want:

Where( {"acetone 5µl", "nil", "methoprene 5µll (40 µg/µl)"}, :treatment )

chang

Community Trekker

Joined:

Jul 11, 2012

Thanks but I got this error message in the log:

Use & to join multiple where conditions, rather than making separate arguments Scriptable[]

pmroz

Super User

Joined:

Jun 23, 2011

I guess that construct doesn't work for the survival analysis.  It works for selecting rows of a table, as in:

dt << get rows where( {"acetone 5µl", "nil", "methoprene 5µll (40 µg/µl)"}, :treatment );