<?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: change informat in string variable in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873829#M345235</link>
    <description>&lt;P&gt;Changing the informat of an &lt;EM&gt;existing&lt;/EM&gt; variable has no effect. Informats play a role only when the data is read initially from a text file, or when used in an INPUT function to create a&amp;nbsp;&lt;EM&gt;new&lt;/EM&gt; variable.&lt;/P&gt;
&lt;P&gt;If data was truncated while being read into SAS, you need to go back to that process and fix it there.&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2023 10:36:39 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-05-04T10:36:39Z</dc:date>
    <item>
      <title>change informat in string variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873826#M345233</link>
      <description>&lt;P&gt;Hello.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to change format in an existing variable that have length $9. but i Need the informat format to be longer than this to include all of the text of the variable name. How can I change informat length for an existing variable in SAS?&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 08:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873826#M345233</guid>
      <dc:creator>user40</dc:creator>
      <dc:date>2023-05-04T08:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: change informat in string variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873829#M345235</link>
      <description>&lt;P&gt;Changing the informat of an &lt;EM&gt;existing&lt;/EM&gt; variable has no effect. Informats play a role only when the data is read initially from a text file, or when used in an INPUT function to create a&amp;nbsp;&lt;EM&gt;new&lt;/EM&gt; variable.&lt;/P&gt;
&lt;P&gt;If data was truncated while being read into SAS, you need to go back to that process and fix it there.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 10:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873829#M345235</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-04T10:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: change informat in string variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873830#M345236</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Informat/format length are totally independent from variable length. You can have variable of length 9 (9 bytes of memory to store data) and informat/format of "arbitrary" length.&lt;/P&gt;
&lt;P&gt;Take a look:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length n 8 c $ 9;
n=42;
c="abcdefghi";
format n 32. c $32767.;
informat n 32. c $32767.;
run;

proc contents data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the output from proc contents shows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1683190476420.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83593i016B6160520DC8BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1683190476420.png" alt="yabwon_0-1683190476420.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Character variable c has length of 9 bytes but format and informat are set to 32767, for numeric n it is 8 vs. 32.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The length of format is just one of information on how to present data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW. that data step is an example how to set length, format and informat. (not only way to do it, but "simplest", an alternative is to use Proc Datasets [especiall when you have larger dataset]).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 08:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873830#M345236</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-04T08:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: change informat in string variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873930#M345253</link>
      <description>&lt;P&gt;From what you describing I understood that you need more length for existing variable to avoid data truncation.&amp;nbsp;Check&amp;nbsp;&lt;A title="this post" href="https://communities.sas.com/t5/SAS-Programming/Changing-the-length-of-a-character-variable/td-p/15905" target="_self"&gt;this post&lt;/A&gt;&amp;nbsp;where&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp; gives multiple examples to alter existing variable length and format. You might find there what you are looking for.&amp;nbsp;&lt;BR /&gt;E.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*altering Variable length*/&lt;BR /&gt;data class;
	set sashelp.class(keep=sex);
run; 
proc sql;
    alter table class
    modify sex char(15);
quit;
data test;
length sex $15;
sex= 'female,male';
run;
data want;
set class test;
proc print;run; 
&lt;BR /&gt;
/*without altering Variable length*/
data class;
	set sashelp.class(keep=sex);
run; 
data test;
length sex $15;
sex= 'female,male';
run;
data want;
set class test;
proc print;run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 17:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-informat-in-string-variable-in-sas/m-p/873930#M345253</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-05-04T17:08:22Z</dc:date>
    </item>
  </channel>
</rss>

