Reformatting data table questionI had an interesting question that I had not seen before I wanted to poll the community. This customer has data come in with one column being the data name and the next column be the value. I have attached an example file. He has hundered of columns come in this way. He wants to move the name from the name column to the top of the data column. Instead of HL_VALUE_1 he was the column header to read TAA_HF. Is there an easy way to do this that I am missing?
Re: Reformatting data table questionPeter, here is a quick way to do it for this dataset.
1) using red triangle in columns pane, select Reorder Columns > Reorder by Data Type
2) in the columns pane, select the HL ..1 -- HL..10 columns.
3) while these columns are still selected, select the 1st row in the data table and press CTRL-C to copy.
4) right-click on the still-selected columns in the columns pane and select Delete Columns
5) select the corresponding continuous columns in the columns pane, then press CTRL-V to paste.
Re: Reformatting data table questionI had a script which was close enough for me to ammend accordingly (note: it isn't robust in the slightlest, but maybe it can be useful...I would recommend saving a copy of the table before trying it):
dt = Current Data Table();
/* Query the user for a column roles. */
cdlg = Column Dialog(
yName = ColList( "Column with name", MinCol( 1 ), MaxCol( ), Data Type("Character"),Modeling Type("Nominal") ),
yData = ColList( "Corresponding data", MinCol( 1 ), MaxCol( ) );
);
/* Unload the values from the Column Dialog */
my_Name = cdlg["yName"];
my_Data = cdlg["yData"];
/*Number of columns chosen*/
numnamecols=N Items(my_Name);
/* Rename columns */
For(i=1,i<=numnamecols,i++,
Column(my_Data[i])<<SET name=""></SET>
Re: Reformatting data table questionOh… my mistake… Sorry!
Since it’s really consistent, you could do a pretty simple script for doing it.
Another thought (if he doesn’t mind things being more manual) is to use the recode feature in that add-in. The way it works, the script is monitoring the recode window generated by the script. When that window closes the script reads the changes in a data table created by the script. The data table isn’t hidden, so you can actually just edit (or copy-paste over the values) in the data table and cancel out of the recode. The script will still read the changes to the data table and update the column names.
M
Re: Reformatting data table questionThanks Mike, That is a super useful add-in. It does not quite do what I need for this case. I have a value in a column that I want to become the name of the next column over.
Re: Reformatting data table questionThis add-in (the shift column name up function) may do what you are after. https://community.jmp.com/t5/JMP-Add-Ins/Column-Name-Utilities-II/ta-p/33626
Best,
M