<?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 Re: Converting numeric variables to character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516549#M139525</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Yes, good call.&lt;/P&gt;
&lt;P&gt;I suppose the actual tables and variables are called something different, so just given as a model.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Nov 2018 03:07:37 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-11-28T03:07:37Z</dc:date>
    <item>
      <title>Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516438#M139477</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a 2 dataset. Let's say A and B. In which A data set contains only 1 variables (num_var) containing all numeric variables names (5 variable) of B data set.&lt;/P&gt;
&lt;P&gt;On the other hand B data set contains 15 variables out of which 5 variable are numeric and 10 are character.&amp;nbsp; So all these 5 variables are listed in A dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now i need to create a macro which trigger to change all those listed in A data set (5 variable) to character for the B dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you need any clarification.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ganesh K&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 18:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516438#M139477</guid>
      <dc:creator>Ganeshk</dc:creator>
      <dc:date>2018-11-27T18:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516514#M139508</link>
      <description>Why would you want to change internal representation?&lt;BR /&gt;It makes no meaningful change - adds no intelligence.&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2018 22:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516514#M139508</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-27T22:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516517#M139511</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A; 
  NUM_VAR='VAR1';
data _null_;
  set A end=LASTOBS;
  if _N_=1 then call execute('data B; set B;');
  call execute(catt(NUM_VAR,'C=put(',NUM_VAR,',32.16); drop'));
  call execute(catt(NUM_VAR,'C; rename '||NUM_VAR,'C=',NUM_VAR,';'));
  if LASTOBS then call execute ('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1 + data B; set B;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;2 + VAR1C=put(VAR1,32.16); drop&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;3 + VAR1C; rename VAR1C=VAR1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;4 + run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 23:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516517#M139511</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-11-27T23:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516530#M139517</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A; 
  NUM_VAR='VAR1';
data _null_;
  set A end=LASTOBS;
  if _N_=1 then call execute('data B; set B;');
  call execute(catt(NUM_VAR,'C=put(',NUM_VAR,',32.16); drop'));
  call execute(catt(NUM_VAR,'C; rename '||NUM_VAR,'C=',NUM_VAR,';'));
  if LASTOBS then call execute ('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1 + data B; set B;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;2 + VAR1C=put(VAR1,32.16); drop&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;3 + VAR1C; rename VAR1C=VAR1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;4 + run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Wouldn't you actually be more likely to use&lt;/P&gt;
&lt;PRE&gt;if _N_=1 then call execute('data NewB; set B;');
&lt;/PRE&gt;
&lt;P&gt;at least for development at least to prevent destroying the original data set while working out the actual PUT format desired?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 23:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516530#M139517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-27T23:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516549#M139525</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Yes, good call.&lt;/P&gt;
&lt;P&gt;I suppose the actual tables and variables are called something different, so just given as a model.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 03:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516549#M139525</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-11-28T03:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516612#M139548</link>
      <description>&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your response. I tried, but need different approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the below Data Set B : Lets consider sashelp.cars data set,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25218i528B508C3E188B43/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The highlighted Cars data set are numeric data variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the listed Data Set A: Those highlight variable&amp;nbsp;that of Data set B is captured as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 121px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25219i5227F3818E34C212/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now using the macro 10 times automatically it need to to pick the variable from Data set A and Change Numeric to character in Data set B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i am converting numeric to character only for 1 variable, i will do code as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 488px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25221i56726B2A2E87DA4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But i want the Variable name need to be picked up from Data set "A" and need to change in Data set B and saved as a new dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know on the query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ganesh K&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 10:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516612#M139548</guid>
      <dc:creator>Ganeshk</dc:creator>
      <dc:date>2018-11-28T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516621#M139551</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17945"&gt;@Ganeshk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
....
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i want the Variable name need to be picked up from Data set "A" and need to change in Data set B and saved as a new dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is exactly what the code posted by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; does.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 11:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/516621#M139551</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-11-28T11:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/518030#M140151</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to thank each and everyone, who took initiative to respond.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;solution is looking more precise and efficient but unfortunately i&amp;nbsp;am not able to decode the code with respect to sashelp.cars dataset. Currently i am using multiple loops and macro logic. some how i am getting the desired result. But if&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;can re-code with the respect to sashelp.cars data. I would accept&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, awaiting for the reply,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Ganesh K&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 12:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/518030#M140151</guid>
      <dc:creator>Ganeshk</dc:creator>
      <dc:date>2018-12-03T12:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric variables to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/518272#M140248</link>
      <description>&lt;P&gt;There was no mention to SASHELP.CARS data in the original question, and changing the code I provided to use different table names should be &lt;STRONG&gt;trivial&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;So I'll leave to you to do as an exercise. You are learning SAS, right? So welcome this opportunity to learn a new technique that's much cleaner than macros.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 23:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-variables-to-character/m-p/518272#M140248</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-12-03T23:39:47Z</dc:date>
    </item>
  </channel>
</rss>

