<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to rename multiple variables from 1 column? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780564#M96267</link>
    <description>&lt;P&gt;I have multiple variables in 1 column (i.e., B,F,T) which needed to be renamed.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Local({dt, col1},
	dt = Data Table("ProductDefect");
	dt &amp;lt;&amp;lt; Begin Data Update;
	col1 = dt &amp;lt;&amp;lt; New Column(dt:LayerData);
	col1 &amp;lt;&amp;lt; Set Name("Side");
	dt &amp;lt;&amp;lt; Move Selected Columns({col1}, after(dt:LayerData));
	For Each Row(
		dt,
		col1[] = If(Contains(dt:LayerData, "B"),
			"Back",
			dt:LayerData
		)
	);
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using this script, I am only changing for B while the other variable (i.e., "F","T") will not be changed. What should be done for all to be renamed in new column; B = Back, F = Front, T = Top?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Aug 2024 12:20:46 GMT</pubDate>
    <dc:creator>Azim</dc:creator>
    <dc:date>2024-08-09T12:20:46Z</dc:date>
    <item>
      <title>How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780564#M96267</link>
      <description>&lt;P&gt;I have multiple variables in 1 column (i.e., B,F,T) which needed to be renamed.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Local({dt, col1},
	dt = Data Table("ProductDefect");
	dt &amp;lt;&amp;lt; Begin Data Update;
	col1 = dt &amp;lt;&amp;lt; New Column(dt:LayerData);
	col1 &amp;lt;&amp;lt; Set Name("Side");
	dt &amp;lt;&amp;lt; Move Selected Columns({col1}, after(dt:LayerData));
	For Each Row(
		dt,
		col1[] = If(Contains(dt:LayerData, "B"),
			"Back",
			dt:LayerData
		)
	);
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using this script, I am only changing for B while the other variable (i.e., "F","T") will not be changed. What should be done for all to be renamed in new column; B = Back, F = Front, T = Top?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 12:20:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780564#M96267</guid>
      <dc:creator>Azim</dc:creator>
      <dc:date>2024-08-09T12:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780577#M96268</link>
      <description>&lt;P&gt;Recode platform can create this type of conversion for you easily.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1723206375103.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66996i48B49353A5935F39/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1723206375103.png" alt="jthi_0-1723206375103.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1723206384261.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66997i2F395EA9788477D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1723206384261.png" alt="jthi_1-1723206384261.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Local({dt, col1},
	dt = Data Table("Big Class");
	dt &amp;lt;&amp;lt; Begin Data Update;
	col1 = dt &amp;lt;&amp;lt; New Column(dt:sex);
	col1 &amp;lt;&amp;lt; Set Name("sex 2");
	dt &amp;lt;&amp;lt; Move Selected Columns({col1}, after(dt:sex));
	dt &amp;lt;&amp;lt; Recode Column(
		dt:sex,
		{Map Value(_rcOrig, {"F", "Female", "M", "Male"}, Unmatched(_rcNow))},
		Update Properties(1),
		Target Column(col1)
	);
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also want to consider using Value Labels column property&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1723206421113.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66998iE7DB11D1DF498B29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1723206421113.png" alt="jthi_2-1723206421113.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It won't change the data in the table, but you will see the "recoded" values&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 12:27:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780577#M96268</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-09T12:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780578#M96269</link>
      <description>&lt;P&gt;Thank you for the feedback!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, by using recode platform, the script cannot be automated as i will have to upload data from database and manually Recode it everytime there are new additions to database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As Sample attached, say, my data keeps being updated from system the naming will be changing continuously while the number and variable maintains (e.g, 1B-xx, 1F-xx, 1T-xx, 2B-xx, 2F-xx, 2T-xx, ...). From system, it will not be automatically displayed whereby B = Back, F = Front, T = Top.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way without having to repeat Recode everytime I want to do analysis?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 12:59:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780578#M96269</guid>
      <dc:creator>Azim</dc:creator>
      <dc:date>2024-08-09T12:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780579#M96270</link>
      <description>&lt;P&gt;Should "2B-New" be "Back" or "2Back-New" and so on?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 13:03:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780579#M96270</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-09T13:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780580#M96271</link>
      <description>&lt;P&gt;Yes, in new column, I only want to specify the "Side". So 2B-New will be "Back", 2T-Basic will be "Top" and so on.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 13:06:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780580#M96271</guid>
      <dc:creator>Azim</dc:creator>
      <dc:date>2024-08-09T13:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780584#M96272</link>
      <description>&lt;P&gt;You can use Recode and Replace string multiple times. I don't know your data, so I'm not sure what would be the best way (I would maybe go with simple regex and if more complicated is necessary you could also do that)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1723208910953.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66999iAED447BDCA5C6E1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1723208910953.png" alt="jthi_0-1723208910953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Repeat this for all with their own patterns&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1723208951197.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67000iAB7C8CBA8AEA76BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1723208951197.png" alt="jthi_1-1723208951197.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And JMP creates you a script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Recode column: ProductDefect
Local({dt},
	dt = Data Table("Sheet1");
	dt &amp;lt;&amp;lt; Begin Data Update;
	dt &amp;lt;&amp;lt; Recode Column(
		dt:ProductDefect,
		{Regex(_rcNow, ".*?\d+B.*", "Back", GLOBALREPLACE),
		Regex(_rcNow, ".*?\d+T.*", "Top", GLOBALREPLACE),
		Regex(_rcNow, ".*?\d+F.*", "Front", GLOBALREPLACE)},
		Update Properties(1),
		Target Column(:ProductDefect)
	);
	dt &amp;lt;&amp;lt; End Data Update;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't want to do it in place,run recode without that enabled&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 13:10:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780584#M96272</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-09T13:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename multiple variables from 1 column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780587#M96273</link>
      <description>&lt;P&gt;Thanks a lot for the help! This works as what I have in mind!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 13:28:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-multiple-variables-from-1-column/m-p/780587#M96273</guid>
      <dc:creator>Azim</dc:creator>
      <dc:date>2024-08-09T13:28:52Z</dc:date>
    </item>
  </channel>
</rss>

