<?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: Build a Format from a Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904331#M357308</link>
    <description>&lt;P&gt;You can use a variable named HLO and set it to O for the "other" observation in your CNTLIN data set.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1e19y6lrektafn1kj6nbvhus59w.htm" target="_blank" rel="noopener"&gt;SAS Help Center: Creating a Format from a CNTLIN= Data Set&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Nov 2023 11:26:29 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2023-11-23T11:26:29Z</dc:date>
    <item>
      <title>Build a Format from a Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904329#M357307</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create format from data set.&lt;/P&gt;
&lt;P&gt;Then I want to use this format in order to create character variable with formatted values.&lt;/P&gt;
&lt;P&gt;My question-&lt;/P&gt;
&lt;P&gt;What is the way that all values that are not in the format data set will get value "Other"?&lt;/P&gt;
&lt;P&gt;So I want that values 100 and 80 will get value "Other" in X_CAT column&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1700735735570.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90121iEFAE6700544364B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1700735735570.png" alt="Ronein_0-1700735735570.png" /&gt;&lt;/span&gt;&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* How Do I Build a Format from a Dataset*/
/* How Do I Build a Format from a Dataset*/
/* How Do I Build a Format from a Dataset*/
/******Example1*******/
/******Example1*******/
/******Example1*******/
data Format_Tbl;
input Code : $char32.  Code_name : $char11. ;
cards;
101 Aberdeen
102 Altrincham
103 Ashford
104 Barnsley
105 Basildon
106 Basingstoke
107 BathFirst
  ;
Run;

data work.outfmt(keep=start label fmtname);  
set work.Format_Tbl(rename=(Code=start Code_name=label));  
fmtname='outfmt';
run;

proc format library=work cntlin=work.outfmt;
run;
/**In  LOG we can see-NOTE: Format OUTFMT has been output.****/


/***Now we can use the format we created***/
/***Now we can use the format we created***/
/***Now we can use the format we created***/
Data tbl;
input x;
cards;
101
106
104
103
100
80
;
Run;

Data want;
set tbl;
X_CAT=PUT(x,outfmt.);
Run;

 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Nov 2023 10:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904329#M357307</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-11-23T10:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Format from a Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904331#M357308</link>
      <description>&lt;P&gt;You can use a variable named HLO and set it to O for the "other" observation in your CNTLIN data set.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1e19y6lrektafn1kj6nbvhus59w.htm" target="_blank" rel="noopener"&gt;SAS Help Center: Creating a Format from a CNTLIN= Data Set&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 11:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904331#M357308</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-11-23T11:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Format from a Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904333#M357309</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Format_Tbl;
input Code : $char32.  Code_name : $char11. ;
cards;
101 Aberdeen
102 Altrincham
103 Ashford
104 Barnsley
105 Basildon
106 Basingstoke
107 BathFirst
  ;
Run;

data work.outfmt(keep=start label fmtname hlo);  
set work.Format_Tbl(rename=(Code=start Code_name=label)) end=last;  
fmtname='outfmt';type='n';
output;
if last then do;start=' ';hlo='o';label='other';output;end;
run;

proc format library=work cntlin=work.outfmt;
run;
/**In  LOG we can see-NOTE: Format OUTFMT has been output.****/


/***Now we can use the format we created***/
/***Now we can use the format we created***/
/***Now we can use the format we created***/
Data tbl;
input x;
cards;
101
106
104
103
100
80
;
Run;

Data want;
set tbl;
X_CAT=PUT(x,outfmt.);
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1700738664606.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90122iC876D56F011F185D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1700738664606.png" alt="Ksharp_0-1700738664606.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 11:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-Format-from-a-Dataset/m-p/904333#M357309</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-23T11:24:22Z</dc:date>
    </item>
  </channel>
</rss>

