<?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: Got table with numerics-only, want to dynamically cast all to char in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764826#M242260</link>
    <description>&lt;P&gt;Can you provide some example data? One way I think off the top of my head is through an array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I'm talking about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
datalines;
1 2 3 4
;
run;

data want;
	set have;
	array all_num [*] _numeric_;
	array all_char [*] $1. chars1 - chars4;
	do i = 1 to dim(all_num);
		all_char[i] = put(all_num[i], 1.);
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Aug 2021 13:09:15 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-08-30T13:09:15Z</dc:date>
    <item>
      <title>Got table with numerics-only, want to dynamically cast all to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764821#M242259</link>
      <description>&lt;P&gt;I've got a table with around 50 variables. Roughly 30 numerics, and 20 chars. Need to create a checksum that's unique for all the 50 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm currently casting the 30 numerics to character. Then I combinine all 50 char values into 1 variable that I use in SHA256 to create the actual checksum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to make this more dynamic. So that I don't&amp;nbsp;need to use 1 PUT-statement for each variable I cast from numeric to character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've written code that identifies all numeric variables and creates a temporary table for them. Is there a way to tell SAS to "cast all variables in this table to character"?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 12:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764821#M242259</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2021-08-30T12:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Got table with numerics-only, want to dynamically cast all to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764826#M242260</link>
      <description>&lt;P&gt;Can you provide some example data? One way I think off the top of my head is through an array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I'm talking about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
datalines;
1 2 3 4
;
run;

data want;
	set have;
	array all_num [*] _numeric_;
	array all_char [*] $1. chars1 - chars4;
	do i = 1 to dim(all_num);
		all_char[i] = put(all_num[i], 1.);
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764826#M242260</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-30T13:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Got table with numerics-only, want to dynamically cast all to char</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764837#M242261</link>
      <description>&lt;P&gt;Could you use CATS to do the heavy lifting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class2;
   set sashelp.class;
   length chk $256;
   chk = sha256(cats(of name--weight));
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Got-table-with-numerics-only-want-to-dynamically-cast-all-to/m-p/764837#M242261</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-08-30T13:47:05Z</dc:date>
    </item>
  </channel>
</rss>

