cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Nats
Level I

Summarizing & Exporting All Value Labels Data From a Table

Is there an easy way in JMP to summarize and export all Value labels information contained in a table (where multiple columns may have different Value Labels, but not all columns will have Value Labels)? Currently doing this manually by doing Recode on every Column with a Value Label, and doing Make Into Data Table. I then combine all the generated data tables together to get a stacked table (see sample files below). 

For now, all Values are numerical, and Value Labels are characters, so stacking is not an issue. 

 

Happy to get both interactive and scripting answers for this one, although I suspect it will be scripting.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Summarizing & Exporting All Value Labels Data From a Table

Not sure if there is a direct interactive way to do this, but here is one way with scripting:

Names Default To Here(1);

//dt = Current Data Table();
dt = Open("$SAMPLE_DATA/CrabSatellites.jmp");
colNames = dt << Get Column Names("String");

dt_stack = New Table("Stacked_Value_Labels",
	New Column("Values", Numeric, "Continuous", Format("Best", 12), ),
	New Column("Labels", Character, "Nominal"),
	New Column("Rating", Character, "Nominal")
);

For(i = 1, i <= N Items(colNames), i++,
	colProp = Arg(Column(dt, colNames[i]) << Get Value Labels);
	If(!IsEmpty(colProp) > 0,
		For(k = 1, k <= N Items(colProp), k++,
			currentColPropExpr = colProp[k];
			dt_stack << Add Rows(
				{Values = Arg(currentColPropExpr, 1), Labels = Arg(currentColPropExpr, 2), Rating = colNames[i]}
			);
		);
	);
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Summarizing & Exporting All Value Labels Data From a Table

Not sure if there is a direct interactive way to do this, but here is one way with scripting:

Names Default To Here(1);

//dt = Current Data Table();
dt = Open("$SAMPLE_DATA/CrabSatellites.jmp");
colNames = dt << Get Column Names("String");

dt_stack = New Table("Stacked_Value_Labels",
	New Column("Values", Numeric, "Continuous", Format("Best", 12), ),
	New Column("Labels", Character, "Nominal"),
	New Column("Rating", Character, "Nominal")
);

For(i = 1, i <= N Items(colNames), i++,
	colProp = Arg(Column(dt, colNames[i]) << Get Value Labels);
	If(!IsEmpty(colProp) > 0,
		For(k = 1, k <= N Items(colProp), k++,
			currentColPropExpr = colProp[k];
			dt_stack << Add Rows(
				{Values = Arg(currentColPropExpr, 1), Labels = Arg(currentColPropExpr, 2), Rating = colNames[i]}
			);
		);
	);
);
-Jarmo
Nats
Level I

Re: Summarizing & Exporting All Value Labels Data From a Table

Thanks, jthi, that works! I'll add in a couple of lines to make sure the data in the original table are Numeric and Continuous (I ran it on a larger data table where the values were Numeric but declared in Column Properties as Character), but I can manage that!