<?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: Proc Format Question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54750#M15188</link>
    <description>Hi:&lt;BR /&gt;
  A SAS user-defined format (what you create with either a VALUE statement or a PICTURE statement) is &lt;BR /&gt;
1) &lt;B&gt;DEFINED&lt;/B&gt; with PROC FORMAT&lt;BR /&gt;
once defined, the format just sits in the format catalog until&lt;BR /&gt;
2) &lt;B&gt;USED&lt;/B&gt; in a FORMAT statement or a FORMAT= option in some procedures (like PROC REPORT or PROC TABULATE).&lt;BR /&gt;
 &lt;BR /&gt;
  So DEFINING the format is only half of the "magic" -- the other "magic" happens when you USE the format. It is the USAGE step that makes the link between the format and the data. Information about the format is stored in the descriptor portion of the SAS dataset, if you assign the format when you read the data. If you use the format in a reporting procedure, then the format is used for that procedure and that procedure only.&lt;BR /&gt;
 &lt;BR /&gt;
  For example, I could have these 2 formats for age. The PROC FORMAT step just DEFINES the formats. The next 2 steps USE the formats.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value agefmt 11-14 = 'Cannot Drive'&lt;BR /&gt;
               15-high = 'Can Drive';&lt;BR /&gt;
 &lt;BR /&gt;
  value agestat 11-12 = 'Pre-teen'&lt;BR /&gt;
                13-14 = 'Teenager'&lt;BR /&gt;
                15-high = 'Young Adult';&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=sashelp.class;&lt;BR /&gt;
  title 'Using AGEFMT format';&lt;BR /&gt;
  tables age;&lt;BR /&gt;
  format age agefmt.;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc means data=sashelp.class;&lt;BR /&gt;
  title 'Using AGESTAT format';&lt;BR /&gt;
  class age;&lt;BR /&gt;
  var height;&lt;BR /&gt;
  format age agestat.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Tue, 09 Feb 2010 23:47:26 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-02-09T23:47:26Z</dc:date>
    <item>
      <title>Proc Format Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54748#M15186</link>
      <description>Hello everyone,&lt;BR /&gt;
&lt;BR /&gt;
I have a general question about proc format.  I am not writing a program or trying to fix an error. I just don't understand how the Value statement know which field it should look at.&lt;BR /&gt;
&lt;BR /&gt;
Here is an example from a sas manual:&lt;BR /&gt;
&lt;BR /&gt;
Data carsurvey;&lt;BR /&gt;
Infile 'c:\mydata\cars.dat';&lt;BR /&gt;
Input Age Sex Income Color $;&lt;BR /&gt;
&lt;BR /&gt;
Proc Format;&lt;BR /&gt;
value gender 1 = 'Male'&lt;BR /&gt;
                   2 = 'Female';&lt;BR /&gt;
value agegroup 13 -&amp;lt; 20  ='Teen'        &lt;BR /&gt;
                      20 -&amp;lt; 65 = 'Adult'&lt;BR /&gt;
                      65 - High = 'Senior';&lt;BR /&gt;
value $col 'W' = 'White'&lt;BR /&gt;
               'B' = 'Blue'&lt;BR /&gt;
               'Y' = 'Yellow';&lt;BR /&gt;
&lt;BR /&gt;
My question is how does each Value statement know which field it should look at?  For example, the first value statement generates a numeric format "Gender" for sex.  But where do we tell it to look at the field sex? &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your input!</description>
      <pubDate>Tue, 09 Feb 2010 23:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54748#M15186</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-02-09T23:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54749#M15187</link>
      <description>for some reason it truncated my posting.. here is the rest&lt;BR /&gt;
&lt;BR /&gt;
Proc Format;&lt;BR /&gt;
value gender 1 = 'Male'&lt;BR /&gt;
                   2 = 'Female';&lt;BR /&gt;
value agegroup 13 -  20 = 'Teen'&lt;BR /&gt;
                      20 - 65 = 'Adult'&lt;BR /&gt;
                      65 - High = 'Senior';&lt;BR /&gt;
value $col 'W' = 'White'&lt;BR /&gt;
               'B' = 'Blue'&lt;BR /&gt;
               'Y' = 'Yellow';&lt;BR /&gt;
&lt;BR /&gt;
My question is how does each Value statement know which field it should look at?  For example, the first value statement generates a numeric format "Gender" for sex.  But where do we tell it to look at the field sex? &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your input!</description>
      <pubDate>Tue, 09 Feb 2010 23:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54749#M15187</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-02-09T23:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54750#M15188</link>
      <description>Hi:&lt;BR /&gt;
  A SAS user-defined format (what you create with either a VALUE statement or a PICTURE statement) is &lt;BR /&gt;
1) &lt;B&gt;DEFINED&lt;/B&gt; with PROC FORMAT&lt;BR /&gt;
once defined, the format just sits in the format catalog until&lt;BR /&gt;
2) &lt;B&gt;USED&lt;/B&gt; in a FORMAT statement or a FORMAT= option in some procedures (like PROC REPORT or PROC TABULATE).&lt;BR /&gt;
 &lt;BR /&gt;
  So DEFINING the format is only half of the "magic" -- the other "magic" happens when you USE the format. It is the USAGE step that makes the link between the format and the data. Information about the format is stored in the descriptor portion of the SAS dataset, if you assign the format when you read the data. If you use the format in a reporting procedure, then the format is used for that procedure and that procedure only.&lt;BR /&gt;
 &lt;BR /&gt;
  For example, I could have these 2 formats for age. The PROC FORMAT step just DEFINES the formats. The next 2 steps USE the formats.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value agefmt 11-14 = 'Cannot Drive'&lt;BR /&gt;
               15-high = 'Can Drive';&lt;BR /&gt;
 &lt;BR /&gt;
  value agestat 11-12 = 'Pre-teen'&lt;BR /&gt;
                13-14 = 'Teenager'&lt;BR /&gt;
                15-high = 'Young Adult';&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=sashelp.class;&lt;BR /&gt;
  title 'Using AGEFMT format';&lt;BR /&gt;
  tables age;&lt;BR /&gt;
  format age agefmt.;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc means data=sashelp.class;&lt;BR /&gt;
  title 'Using AGESTAT format';&lt;BR /&gt;
  class age;&lt;BR /&gt;
  var height;&lt;BR /&gt;
  format age agestat.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 09 Feb 2010 23:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54750#M15188</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-02-09T23:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54751#M15189</link>
      <description>Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
Thank you for the detailed explanation as always.  Your input is always appreciated!&lt;BR /&gt;
&lt;BR /&gt;
Kevin</description>
      <pubDate>Wed, 10 Feb 2010 16:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-Question/m-p/54751#M15189</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-02-10T16:37:37Z</dc:date>
    </item>
  </channel>
</rss>

