<?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 permanently change the format of a variable in a SAS data set  .sas7bdat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541735#M149636</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a SAS data set .sas7bdat.&amp;nbsp;I am trying to permanently change the format of one of the variables to 7 digits (dropping the 8th one).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to try a way to only change the format of that variable without having to upload the whole data set again and without having to change all the subsequent code already written that uses that data set.&lt;/P&gt;&lt;P&gt;The purpose of that manipulation is to merge the data set with another one and 'name' is the common variable so I only need to change the number of digit for the merge to happen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code for the merge is in SQL.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ABC;
set learn.ABC;
informat name $8.;
format name $7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I ran the code that appear above, the log didn't report any error , but when I did the proc sql merge, the name variable still had 8 digit.&lt;/P&gt;&lt;P&gt;your help on this little beginner's question would be very helpful&lt;/P&gt;</description>
    <pubDate>Sat, 09 Mar 2019 21:27:41 GMT</pubDate>
    <dc:creator>Dublin187</dc:creator>
    <dc:date>2019-03-09T21:27:41Z</dc:date>
    <item>
      <title>How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541735#M149636</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a SAS data set .sas7bdat.&amp;nbsp;I am trying to permanently change the format of one of the variables to 7 digits (dropping the 8th one).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to try a way to only change the format of that variable without having to upload the whole data set again and without having to change all the subsequent code already written that uses that data set.&lt;/P&gt;&lt;P&gt;The purpose of that manipulation is to merge the data set with another one and 'name' is the common variable so I only need to change the number of digit for the merge to happen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code for the merge is in SQL.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ABC;
set learn.ABC;
informat name $8.;
format name $7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I ran the code that appear above, the log didn't report any error , but when I did the proc sql merge, the name variable still had 8 digit.&lt;/P&gt;&lt;P&gt;your help on this little beginner's question would be very helpful&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 21:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541735#M149636</guid>
      <dc:creator>Dublin187</dc:creator>
      <dc:date>2019-03-09T21:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541736#M149637</link>
      <description>&lt;P&gt;A format only changes the way a variable is&amp;nbsp;&lt;EM&gt;displayed&lt;/EM&gt;, not its&amp;nbsp;&lt;EM&gt;contents&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;To remove the 8th position, use the substr() function.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 21:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541736#M149637</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-09T21:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541740#M149638</link>
      <description>&lt;P&gt;SQL join expressions such as &lt;EM&gt;&lt;STRONG&gt;a.name=b.name&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; are evaluated on the column values, not the&lt;EM&gt; formatted&lt;/EM&gt; values. If you want the comparison to be based on the shortest string, use a truncated string comparison operator: &lt;EM&gt;&lt;STRONG&gt;a.name eqt b.name.&lt;/STRONG&gt;&lt;/EM&gt; If you want the comparison to be based on the first 7 characters, use a substring function: &lt;EM&gt;&lt;STRONG&gt;a.name=substr(b.name,1,7)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 21:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541740#M149638</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-09T21:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541742#M149639</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;thank you for your reply. the substr() statement worked.&lt;/P&gt;&lt;P&gt;however in the next step(in the Proc SQL merge ), the new sas data set isn't being used. Do you know how to make this change permanent in the .sas7bdat file?&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 21:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541742#M149639</guid>
      <dc:creator>Dublin187</dc:creator>
      <dc:date>2019-03-09T21:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541746#M149641</link>
      <description>&lt;P&gt;If your &lt;EM&gt;merge&lt;/EM&gt; is an inner join (and not a left or right join), just keep the other version of the key (the shorter name) in your select clause.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 22:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541746#M149641</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-09T22:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541747#M149642</link>
      <description>&lt;P&gt;You've already gotten good answers regarding solving the base problem, however no one has yet mentioned the direct answer to your original question. To change the format, informat and length of variables that already exist in a dataset, the format, informat and/or length statements have to come BEFORE the set statement. e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
  length name $9;
  format name $9.;
  informat name $9.;
  set sashelp.class;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 22:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541747#M149642</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-03-09T22:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently change the format of a variable in a SAS data set  .sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541798#M149661</link>
      <description>&lt;P&gt;MERGE happens in data steps, proc sql does JOINS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please supply some example data in usable form (data steps with datalines, see my footnotes), and your current merge (or join) code that does not work as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Substr() can be used in the ON or WHERE clauses of SQL joins.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2019 07:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-permanently-change-the-format-of-a-variable-in-a-SAS-data/m-p/541798#M149661</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-10T07:11:09Z</dc:date>
    </item>
  </channel>
</rss>

