ricerca e sostituzione dell'intestazione di colonnaCiao,
Posso sostituire il nome dell'intestazione della colonna con il nome esatto utilizzando : altezza << Imposta nome ("test");
Se ho un elenco di testo che voglio sostituire con "".
Come procedo con quello?
"nome" "Ora" "sesso" "altezza abc peso" "peso xyz" "12 test di altezza"
KATIE 12 F 59 95 59
LOUISE 12 F 61123 61
Uscita finale:
"nome" "Ora" "sesso" "abc" "xyz" "12 test"
Names Default To Here( 1 );
dt = Open( "C:/JSL/BigClass.jmp" );
headerList = dt << get column names( string );
//:height << Set Name( "test" );
For( i = 1, i <= N Items( headerList ), i++,
If( (headerList[i] == "height" || headerList[i] == "weight"), //trying to find any column header has height or weight and replace with ""
Column( dt, colList[i] ) << set name( " " ) //above are just two examples, maybe put it in list and loop?
)
);
ScriptingRi: ricerca e sostituzione dell'intestazione di colonnaCiao Sam,
Ho trovato 2 problemi nel tuo script:
- Hai usato la concatenazione "||" codice per rappresentare la tua istruzione "Or" (dovrebbe essere "|")
- JMP non consente di denominare la colonna come "".
Inoltre, di solito è più facile e veloce chiamare la colonna in base al numero invece di scorrere l'elenco dei nomi delle colonne
Quindi, ecco cosa ho pensato:
Names Default To Here( 1 );
dt = Open( "C:\Program Files\SAS\JMP\14\Samples\Data\Big Class.jmp" );
headerList = dt << get column names( string );
For( i = 1, i <= N Items( headerList ), i++,
If( (headerList[i] == "height" | headerList[i] == "weight"), //Fixed the "Or" statement
Column( dt, i ) << set name(substitute (headerList [i], "e", "x")) //Used the substitute function as an example, you can replace any string with ""?
)
);
Ri: ricerca e sostituzione dell'intestazione di colonnaHo provato a definire l'elenco in anticipo e fare un doppio ciclo annidato. Sostituisce solo stringReplace [3].
headerList = dt << get column names( string );
stringReplace = List();
stringReplace[1] = "height";
stringReplace[2] = "e";
stringReplace[3] = "a";
For( i = 1, i <= N Items( headerList ), i++,
For( j = 1, j <= N Items( stringReplace ), j++,
Column( dt, i ) << set name( Substitute(headerList[i], stringReplace[j], "" ) )
);
);