<?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: Trying to understand formats in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942018#M45178</link>
    <description>&lt;P&gt;It appears that the data set is intended to be used with the CNTLIN option of Proc Format to create a format named DISPOSITION for use with character values.&lt;/P&gt;
&lt;P&gt;The structure of a CNTLIN data set requires certain variables, minimum is the name of the format which must be in a variable named FMTNAME, Start as the value and Label as the text to display instead of the value of Start.&lt;/P&gt;
&lt;P&gt;There are other variables to indicate other properties set as options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know how to write small custom format you could use the CNTLOUT= option on proc format to create a data set that describes the format(s). That may help understand a bit better what the variables must look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Sort is not needed and could actually be improper if the set had more than one value of FMTNAME as the Format procedure would expect all of the lines for a single format to be together in the data set. The NODUPEKEY is there to prevent errors of multiple observations with the same Start value. Again proc format except for very specific purposes expects to see values in the Start (or End if a range of numeric values is used) only once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect to see something like this to actually create the format for use:&lt;/P&gt;
&lt;PRE&gt;Proc format &amp;lt;library=somelib&amp;gt; cntlin=disp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This would be similar to writing a Proc format value statement like this:&lt;/P&gt;
&lt;PRE&gt;Proc format;
Value $disposition
'01' = 'Meaning for code 01'
'02' = 'Meaning for code 02'
;
run;
&lt;/PRE&gt;
&lt;P&gt;The '01' '02' are the START values. The 'Meaning for code' text are the values of LABEL and $disposition is the FMTNAME value.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2024 17:56:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-30T17:56:30Z</dc:date>
    <item>
      <title>Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942015#M45177</link>
      <description>&lt;P&gt;Hi, I just wanted to see if someone could explain what this means exactly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data disp;
     set trcb.DispositionCode_Xref;

     length start $2 label $100;
     fmtname = '$disposition';

     start = Disp_Code;
     label = Disp_Code_Desc;

     keep start label fmtname;
run;

proc sort data=disp nodupkey;
     by start;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not well-versed on formats that much. I get the gist but when I look at this I'm a bit lost on what exactly this means. Thank you, any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942015#M45177</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-08-30T17:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942018#M45178</link>
      <description>&lt;P&gt;It appears that the data set is intended to be used with the CNTLIN option of Proc Format to create a format named DISPOSITION for use with character values.&lt;/P&gt;
&lt;P&gt;The structure of a CNTLIN data set requires certain variables, minimum is the name of the format which must be in a variable named FMTNAME, Start as the value and Label as the text to display instead of the value of Start.&lt;/P&gt;
&lt;P&gt;There are other variables to indicate other properties set as options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know how to write small custom format you could use the CNTLOUT= option on proc format to create a data set that describes the format(s). That may help understand a bit better what the variables must look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Sort is not needed and could actually be improper if the set had more than one value of FMTNAME as the Format procedure would expect all of the lines for a single format to be together in the data set. The NODUPEKEY is there to prevent errors of multiple observations with the same Start value. Again proc format except for very specific purposes expects to see values in the Start (or End if a range of numeric values is used) only once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect to see something like this to actually create the format for use:&lt;/P&gt;
&lt;PRE&gt;Proc format &amp;lt;library=somelib&amp;gt; cntlin=disp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This would be similar to writing a Proc format value statement like this:&lt;/P&gt;
&lt;PRE&gt;Proc format;
Value $disposition
'01' = 'Meaning for code 01'
'02' = 'Meaning for code 02'
;
run;
&lt;/PRE&gt;
&lt;P&gt;The '01' '02' are the START values. The 'Meaning for code' text are the values of LABEL and $disposition is the FMTNAME value.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942018#M45178</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-30T17:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942021#M45179</link>
      <description>&lt;P&gt;You have code to create a PROC FORMAT CNLTLIN= data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To create the character value label format $DISPOSITION using this data you need to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format CNTLIN=disp;
   quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The you would be able to use $disposition. in a format statement or PUT function.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942021#M45179</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-08-30T17:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942027#M45180</link>
      <description>&lt;P&gt;What part do you not understand?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The SAS code you shared?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The DATA step is making a new dataset from an old dataset.&amp;nbsp; The dataset it is making can be used to create a FORMAT.&lt;/P&gt;
&lt;P&gt;The PROC SORT step is to order the observations and make sure the same START value does not appear more than once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How to convert that dataset into a format?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Use PROC FORMAT with the CNTLIN= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format cntlin=disp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What a FORMAT does?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Formats are used to convert values into text.&amp;nbsp; In this case the values are character strings up to two bytes long.&amp;nbsp; Your dataset can be used to make a format named $DISPOSITION that converts values that match the values of DISP_CODE into text strings of the corresponding value of DISP_CODE_DESC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How to use a FORMAT?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You would use the $DISPOSTION format with any variable that has the same set of 2 letter codes that was in your dataset so that they are printed/displayed/converted to text.&amp;nbsp; Say you have a dataset named EVENTS that had a variable named EVENT_DISP that was using those same 2 letter codes.&amp;nbsp; You could then get a summary of how many events ended with each disposition code using a step like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=events;
  tables event_disp;
  format event_disp $disposition. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 18:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942027#M45180</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-30T18:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942063#M45181</link>
      <description>Thank you!</description>
      <pubDate>Fri, 30 Aug 2024 21:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942063#M45181</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-08-30T21:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand formats</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942407#M45193</link>
      <description>&lt;P&gt;The code snippet you've provided is creating a custom format in SAS, and I'll walk you through each step.&lt;/P&gt;&lt;P&gt;Step-by-Step Explanation&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Creating the Dataset &lt;CODE&gt;disp&lt;/CODE&gt;:&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;data disp;&lt;BR /&gt;set trcb.DispositionCode_Xref;&lt;/P&gt;&lt;P&gt;length start $2 label $100;&lt;BR /&gt;fmtname = '$disposition';&lt;/P&gt;&lt;P&gt;start = Disp_Code;&lt;BR /&gt;label = Disp_Code_Desc;&lt;/P&gt;&lt;P&gt;keep start label fmtname;&lt;BR /&gt;run;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;data disp;&lt;/CODE&gt;&lt;/STRONG&gt;: This starts a new dataset named &lt;CODE&gt;disp&lt;/CODE&gt;.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;set trcb.DispositionCode_Xref;&lt;/CODE&gt;&lt;/STRONG&gt;: This reads in data from an existing dataset called &lt;CODE&gt;trcb.DispositionCode_Xref&lt;/CODE&gt;.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;length start $2 label $100;&lt;/CODE&gt;&lt;/STRONG&gt;: This sets the length of two new variables:&lt;UL&gt;&lt;LI&gt;&lt;CODE&gt;start&lt;/CODE&gt; (length 2 characters)&lt;/LI&gt;&lt;LI&gt;&lt;CODE&gt;label&lt;/CODE&gt; (length 100 characters)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;fmtname = '$disposition';&lt;/CODE&gt;&lt;/STRONG&gt;: This assigns the value &lt;CODE&gt;'$disposition'&lt;/CODE&gt; to a new variable called &lt;CODE&gt;fmtname&lt;/CODE&gt;. This variable will be used to define the name of the custom format.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;start = Disp_Code;&lt;/CODE&gt;&lt;/STRONG&gt;: This assigns the value from the variable &lt;CODE&gt;Disp_Code&lt;/CODE&gt; to the &lt;CODE&gt;start&lt;/CODE&gt; variable. In the context of creating formats, &lt;CODE&gt;start&lt;/CODE&gt; represents the values that will be formatted.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;label = Disp_Code_Desc;&lt;/CODE&gt;&lt;/STRONG&gt;: This assigns the value from the variable &lt;CODE&gt;Disp_Code_Desc&lt;/CODE&gt; to the &lt;CODE&gt;label&lt;/CODE&gt; variable. The &lt;CODE&gt;label&lt;/CODE&gt; represents the formatted output that corresponds to the &lt;CODE&gt;start&lt;/CODE&gt; value.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;keep start label fmtname;&lt;/CODE&gt;&lt;/STRONG&gt;: This keeps only the &lt;CODE&gt;start&lt;/CODE&gt;, &lt;CODE&gt;label&lt;/CODE&gt;, and &lt;CODE&gt;fmtname&lt;/CODE&gt; variables in the final &lt;CODE&gt;disp&lt;/CODE&gt; dataset, discarding any others from the original dataset.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Summary of this step&lt;/STRONG&gt;: You're creating a new dataset called &lt;CODE&gt;disp&lt;/CODE&gt; that contains three variables: &lt;CODE&gt;start&lt;/CODE&gt; (the value to format), &lt;CODE&gt;label&lt;/CODE&gt; (the formatted output), and &lt;CODE&gt;fmtname&lt;/CODE&gt; (the name of the format).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Sorting the Dataset:&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=disp nodupkey;&lt;BR /&gt;by start;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;proc sort data=disp nodupkey;&lt;/CODE&gt;&lt;/STRONG&gt;: This sorts the &lt;CODE&gt;disp&lt;/CODE&gt; dataset by the &lt;CODE&gt;start&lt;/CODE&gt; variable. The &lt;CODE&gt;nodupkey&lt;/CODE&gt; option removes any duplicate records based on the &lt;CODE&gt;start&lt;/CODE&gt; variable, ensuring that each value to be formatted is unique.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;by start;&lt;/CODE&gt;&lt;/STRONG&gt;: This specifies that the sorting should be done by the &lt;CODE&gt;start&lt;/CODE&gt; variable.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Summary of this step&lt;/STRONG&gt;: You're ensuring that the dataset &lt;CODE&gt;disp&lt;/CODE&gt; is sorted by the &lt;CODE&gt;start&lt;/CODE&gt; values and that there are no duplicate &lt;CODE&gt;start&lt;/CODE&gt; values.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;What Does This All Mean?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This code is preparing a dataset that will be used to create a custom format in SAS.&lt;/LI&gt;&lt;LI&gt;A format in SAS is a way to map values (like &lt;CODE&gt;Disp_Code&lt;/CODE&gt;) to corresponding labels (like &lt;CODE&gt;Disp_Code_Desc&lt;/CODE&gt;), so that when you apply this format to a variable, the value gets displayed as the label.&lt;/LI&gt;&lt;LI&gt;In this specific case, a custom format called &lt;CODE&gt;'$disposition'&lt;/CODE&gt; is being created, which will map each &lt;CODE&gt;Disp_Code&lt;/CODE&gt; to its corresponding &lt;CODE&gt;Disp_Code_Desc&lt;/CODE&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Final Step (Not in the Code)&lt;/P&gt;&lt;P&gt;Typically, after preparing this dataset (&lt;CODE&gt;disp&lt;/CODE&gt;), you would use the &lt;CODE&gt;PROC FORMAT&lt;/CODE&gt; procedure to actually create the format from this dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format cntlin=disp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;proc format cntlin=disp;&lt;/CODE&gt;&lt;/STRONG&gt;: This tells SAS to create a format based on the &lt;CODE&gt;disp&lt;/CODE&gt; dataset you've created.&lt;/LI&gt;&lt;LI&gt;Once this is done, you can use the &lt;CODE&gt;'$disposition'&lt;/CODE&gt; format to display &lt;CODE&gt;Disp_Code&lt;/CODE&gt; values as their corresponding &lt;CODE&gt;Disp_Code_Desc&lt;/CODE&gt; labels in reports or datasets.&lt;/LI&gt;&lt;/UL&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>Wed, 04 Sep 2024 01:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Trying-to-understand-formats/m-p/942407#M45193</guid>
      <dc:creator>Sarath_A_SAS</dc:creator>
      <dc:date>2024-09-04T01:17:11Z</dc:date>
    </item>
  </channel>
</rss>

