<?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: formatting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497976#M132190</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;do you have to define a variable's format if its length is greater than 8?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;NO&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only character variables can have a storage length greater than 8.&amp;nbsp; And SAS does not need to have a format attached to a character variable to know how to display it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact most variables do not need to have formats attached to them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using DATE/TIME/DATETIME values then you will want to attach a format to make the readable.&amp;nbsp; &amp;nbsp;If you have really large numbers you might want to use the COMMA format to make them easier to read.&amp;nbsp; If you have non-integer values you might want to use a format to fix the number of decimal places that are displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some people seem to think that&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format longvar $50. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is a way to define &lt;STRONG&gt;longvar&lt;/STRONG&gt; as a character variable of length 50 bytes.&amp;nbsp; But that would only happen if that was the first place that the variable was defined.&amp;nbsp; Then SAS would guess that you meant to define it with a length of 50 because you attached a format with a width of 50 to it.&amp;nbsp; If you really want to define the length use a LENGTH statement (or the LENGTH= attribute of the ATTRIB statement).&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 20:12:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-09-21T20:12:25Z</dc:date>
    <item>
      <title>formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497896#M132144</link>
      <description>&lt;P&gt;is proc format permanent?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when do you use format statement in data step? do you have to define a variable's format if its length is greater than 8?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 16:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497896#M132144</guid>
      <dc:creator>clqa</dc:creator>
      <dc:date>2018-09-21T16:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497909#M132153</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;is proc format permanent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is any code permanent?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;when do you use format statement in data step?&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use formats whenever you want the value of the variable to appear in a way that is defined by the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;do you have to define a variable's format if its length is greater than 8?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables whose length is greater than 8 do not have to have a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 17:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497909#M132153</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-21T17:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497941#M132171</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;is proc format permanent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, no and maybe.&lt;/P&gt;
&lt;P&gt;A format can be permanently assigned to a variable. Typically in a data step but other procedures can do so. Proc DATASETS is intended to change characteristics of a data set such as variable formats, variable names, variable labels as some other things. Most procedures that produce output sets involving the formatted value of a variable will have that format "permanently" assigned in the output set even though it wasn't in the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While the format may be permanently assigned to a variable the format itself might be temporary. You can create custom formats with proc format. Default will place the format definition in the WORK library. So a permanent data set with such a format may not find the format definition if the format code isn't run in the next SAS session. There are options with Proc Format to write the format definitions to a library and then tell SAS to find the definitions in that location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format can also be used temporarily for specific output at need. For example run this example and see the difference in the output.&lt;/P&gt;
&lt;P&gt;The SASHELP.CLASS data set should be included in your installation.&lt;/P&gt;
&lt;PRE&gt;Proc freq data=sashelp.class;
   title "Default format";
   tables height;
run;
Proc freq data=sashelp.class;
   title "Assigned F2 Format";
   tables height;
   format height f2.;
run;title;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 18:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497941#M132171</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-21T18:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497953#M132179</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;is proc format permanent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, it's been there for as long as I've been using SAS, so I guess, yes.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 18:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497953#M132179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-21T18:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497975#M132189</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;is proc format permanent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format can be permanently assigned to a variable. Typically in a data step but other procedures can do so. Proc DATASETS is intended to change characteristics of a data set such as variable formats, variable names, variable labels as some other things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;... but the format can be "un-assigned" in the next data step or next PROC. Permanence is not guaranteed.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 20:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497975#M132189</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-21T20:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497976#M132190</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234925"&gt;@clqa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;do you have to define a variable's format if its length is greater than 8?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;NO&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only character variables can have a storage length greater than 8.&amp;nbsp; And SAS does not need to have a format attached to a character variable to know how to display it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact most variables do not need to have formats attached to them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using DATE/TIME/DATETIME values then you will want to attach a format to make the readable.&amp;nbsp; &amp;nbsp;If you have really large numbers you might want to use the COMMA format to make them easier to read.&amp;nbsp; If you have non-integer values you might want to use a format to fix the number of decimal places that are displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some people seem to think that&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format longvar $50. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is a way to define &lt;STRONG&gt;longvar&lt;/STRONG&gt; as a character variable of length 50 bytes.&amp;nbsp; But that would only happen if that was the first place that the variable was defined.&amp;nbsp; Then SAS would guess that you meant to define it with a length of 50 because you attached a format with a width of 50 to it.&amp;nbsp; If you really want to define the length use a LENGTH statement (or the LENGTH= attribute of the ATTRIB statement).&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 20:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting/m-p/497976#M132190</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-21T20:12:25Z</dc:date>
    </item>
  </channel>
</rss>

