Subscribe Bookmark RSS Feed

Recoding Data

siwong1210

Community Trekker

Joined:

Mar 2, 2015

Hi All,

First time trying to write a script to simplify the iterative process of recoding. The general idea is to just drag the variable into it's respective dialog box and be able to recode (in the same column or into new columns) based on where you drag it into but having trouble getting past the second step of referencing the column list from the dialog boxes.

Current Data Table() << Begin Data Update;

Delete Symbols();

dt = Current Data Table();

//Load Dialog Boxes & Capture Variables

result = Column Dialog(

  A1 = ColList( "Missing Recode" ),

  B1 = ColList( "Top 1-2 Ranking" ),

  C1 = ColList( "Likert 5 Point Scale - Top 1" ),

  D1 = ColList( "Likert 7 Point Scale - Top 2" )

);

//Need to reference column list??

For Each Row(

//0-1 Recode

  If( Is Missing(result), result = 0 )

);

Current Data Table() << End Data Update;

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

As you define the column dialog, a list will be returned when the user clicks the OK or Cancel button. You should examine the Button( 0 | 1 ) item to decide which happened and proceed or quit accordingly:

If( result]"Button"] == -1, Throw( "User cancelled" ) );

In this case, it is a list of four assignments. Remove the last item and evaluate the list:

Remove From( result ); Eval List( result );

Now each assignment is done. Use the individual variables to decide what to do:

If( N Items( A1 ),

  For Each Row(

    If( Is Missing( A1[] ), A1[] = 0 );

  );

);

If( N Items( B1 ),

...

);

...

Learn it once, use it forever!
2 REPLIES
Solution

As you define the column dialog, a list will be returned when the user clicks the OK or Cancel button. You should examine the Button( 0 | 1 ) item to decide which happened and proceed or quit accordingly:

If( result]"Button"] == -1, Throw( "User cancelled" ) );

In this case, it is a list of four assignments. Remove the last item and evaluate the list:

Remove From( result ); Eval List( result );

Now each assignment is done. Use the individual variables to decide what to do:

If( N Items( A1 ),

  For Each Row(

    If( Is Missing( A1[] ), A1[] = 0 );

  );

);

If( N Items( B1 ),

...

);

...

Learn it once, use it forever!
siwong1210

Community Trekker

Joined:

Mar 2, 2015

Thanks Mark! This helps tremendously and also leads me to my next question. Take A1 for example, my idea was to recode all of the "." to "0". Would I need to be using match (basically referencing the script outputted by JMP when recoding) or am I still able to use the if statement in this case? Or I'm probably using Is Missing incorrectly?