Subscribe Bookmark RSS Feed

Select all columns at once from a table

I have multiple tables which contain data imported from csv files. unfortunately not all tables are the same length and vary in length day to day. however id still like to be able to convert all columns to datatype character, is there any command within jmp scripting that would allow me to do this without having to specify individual columns (since i dont know how many columns there will be in total)
5 REPLIES
you could use a short script that makes a list of all the column names, then iteratively assigns a property to each column.
thanks for the reply

Would you have any samplecode that would do that?
Essentially what im trying to do is to convert all columns to "character".
The closest i have got so far is to use this code
_________________________________
dt=DataTable("Log60");
cc=dt<ncols = N Items(cc);

This returns the name of columns which are "numeric"
_________________________________

The scripting guide then says to use this type of loop to select all the columns listed from the code above
________________________
for(i=1,i<=ncols,i++,
cc(i)<________________________

but this one doesnt work for me - it says invalid row number -1
XanGregg

Staff

Joined:

Jun 23, 2011

It works for me, using "cc[ i ]" instead of "cc(i)" . Do you have a column called cc or i that might be conflicting with the variables? Try cc[ i ]<
Edit: The forum software seems to use square brackets for styling, so the message got corrupted. Trying with a space.


Message was edited by: xan@jmp
Give this a shot

dt=current data table();
::cc = ::dt << Get Column Names( Continuous );
::ncols = N Items( ::cc );
For( ::i = 1, ::i <= ::ncols, ::i++,
::name = ::cc[::i];
::cc[::i] << Data Type( Character );
Current Data Table() << Run Formulas;
);
That script posting got scrambled somehow

go over to the Great Lakes Yahoo Group, I posted for you over there

http://tech.groups.yahoo.com/group/GLJUG/