<?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 FORMAT FROM SAS DATASET AND WRITE IT TO A TEXT FILE in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488968#M72045</link>
    <description>&lt;P&gt;I think you're possibly misunderstanding the use of CNTLIN...it doesn't create a text file, it creates the format that can be used, so what would happen after you ran the PROC FORMAT. Is there any specific reason you need the PROC FORMAT code as shown? You can use CNTLOUT to generate the data set back out if needed....but it still wouldn't be in that style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120272"&gt;@sayanapex06&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA XXX ;&lt;BR /&gt;LENGTH CC $2. FLG $1. ;&lt;BR /&gt;INFILE DATALINES DLM = '~' ;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; @1 CC FLG ;&lt;BR /&gt;DATALINES ;&lt;BR /&gt;AB~Y&lt;BR /&gt;BC~N&lt;BR /&gt;CD~Y&lt;BR /&gt;DF~N&lt;BR /&gt;TY~N&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;DATA CREATE_FORMAT ;&lt;BR /&gt;RETAIN FMTNAME 'TESTFR' TYPE 'C' ;&lt;BR /&gt;SET XXX END=EOF ;&lt;BR /&gt;START = CC ;&lt;BR /&gt;LABEL = FLG ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;IF EOF ; /* ON LAST RECORD */&lt;BR /&gt;HLO = 'O' ;&lt;BR /&gt;LABEL = 'X' ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;LIBNAME LIBRARY '/sas/data/DEV_TEST/SAYAN_TEST/' ;&lt;/P&gt;
&lt;P&gt;PROC FORMAT LIBRARY = LIBRARY CNTLIN = CREATE_FORMAT ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not getting the desired output which should look like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FORMAT ;&lt;/P&gt;
&lt;P&gt;VALUE $TESTFR&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;'AB' = 'Y'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...........(etc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting it in binary form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pleas help me with getting the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sayan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 16:29:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-22T16:29:10Z</dc:date>
    <item>
      <title>Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488963#M72043</link>
      <description>&lt;P&gt;I have the following code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA XXX ;&lt;BR /&gt;LENGTH CC $2. FLG $1. ;&lt;BR /&gt;INFILE DATALINES DLM = '~' ;&lt;BR /&gt;INPUT @1 CC FLG ;&lt;BR /&gt;DATALINES ;&lt;BR /&gt;AB~Y&lt;BR /&gt;BC~N&lt;BR /&gt;CD~Y&lt;BR /&gt;DF~N&lt;BR /&gt;TY~N&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;DATA CREATE_FORMAT ;&lt;BR /&gt;RETAIN FMTNAME 'TESTFR' TYPE 'C' ;&lt;BR /&gt;SET XXX END=EOF ;&lt;BR /&gt;START = CC ;&lt;BR /&gt;LABEL = FLG ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;IF EOF ; /* ON LAST RECORD */&lt;BR /&gt;HLO = 'O' ;&lt;BR /&gt;LABEL = 'X' ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;LIBNAME LIBRARY '/sas/data/DEV_TEST/SAYAN_TEST/' ;&lt;/P&gt;
&lt;P&gt;PROC FORMAT LIBRARY = LIBRARY CNTLIN = CREATE_FORMAT ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not getting the desired output which should look like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FORMAT ;&lt;/P&gt;
&lt;P&gt;VALUE $TESTFR&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;'AB' = 'Y'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...........(etc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting it in binary form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pleas help me with getting the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sayan&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488963#M72043</guid>
      <dc:creator>sayanapex06</dc:creator>
      <dc:date>2018-08-22T16:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: BUILD FORMAT FROM SAS DATASET AND WRITE IT TO A TEXT FILE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488968#M72045</link>
      <description>&lt;P&gt;I think you're possibly misunderstanding the use of CNTLIN...it doesn't create a text file, it creates the format that can be used, so what would happen after you ran the PROC FORMAT. Is there any specific reason you need the PROC FORMAT code as shown? You can use CNTLOUT to generate the data set back out if needed....but it still wouldn't be in that style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120272"&gt;@sayanapex06&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA XXX ;&lt;BR /&gt;LENGTH CC $2. FLG $1. ;&lt;BR /&gt;INFILE DATALINES DLM = '~' ;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; @1 CC FLG ;&lt;BR /&gt;DATALINES ;&lt;BR /&gt;AB~Y&lt;BR /&gt;BC~N&lt;BR /&gt;CD~Y&lt;BR /&gt;DF~N&lt;BR /&gt;TY~N&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;DATA CREATE_FORMAT ;&lt;BR /&gt;RETAIN FMTNAME 'TESTFR' TYPE 'C' ;&lt;BR /&gt;SET XXX END=EOF ;&lt;BR /&gt;START = CC ;&lt;BR /&gt;LABEL = FLG ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;IF EOF ; /* ON LAST RECORD */&lt;BR /&gt;HLO = 'O' ;&lt;BR /&gt;LABEL = 'X' ;&lt;BR /&gt;OUTPUT ;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;LIBNAME LIBRARY '/sas/data/DEV_TEST/SAYAN_TEST/' ;&lt;/P&gt;
&lt;P&gt;PROC FORMAT LIBRARY = LIBRARY CNTLIN = CREATE_FORMAT ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not getting the desired output which should look like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FORMAT ;&lt;/P&gt;
&lt;P&gt;VALUE $TESTFR&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;'AB' = 'Y'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...........(etc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting it in binary form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pleas help me with getting the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sayan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488968#M72045</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T16:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: BUILD FORMAT FROM SAS DATASET AND WRITE IT TO A TEXT FILE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488971#M72046</link>
      <description>&lt;P&gt;I need it to generalize and shorten a huge process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct even with CNTLOUT, I didnt get the desired format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So could you suggest, how I can try build a format from a SAS dataset in the desired proc format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sayan&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488971#M72046</guid>
      <dc:creator>sayanapex06</dc:creator>
      <dc:date>2018-08-22T16:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: BUILD FORMAT FROM SAS DATASET AND WRITE IT TO A TEXT FILE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488972#M72047</link>
      <description>&lt;P&gt;You'd have to do it manually, which is why I don't understand why this would be needed or how it would help.&lt;/P&gt;
&lt;P&gt;It's also difficult because you need to account for the possibility of a multilabel format or the other and/or missing values. There's also intervals that need to be accounted for...so it's definitely possible but a set of tedious programming using PUT statements. If you know it's a one to one coding that's a few put statements but you still need to account for the different format types and such.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try and search on Lexjansen to see if someone created a macro or code before PROC FORMAT had CNTLIN but you're looking for really old papers at that point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://lexjansen.com/search/searchresults.php?q=create%20proc%20format%20code%20from%20data%20set" target="_blank"&gt;https://lexjansen.com/search/searchresults.php?q=create%20proc%20format%20code%20from%20data%20set&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a specific reason, PROC FORMAT with CNTLIN doesn't do exactly what you need? It's more concise and does the exact same thing. I genuinely cannot see the use case (besides an academic) for this exercise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488972#M72047</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T16:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488973#M72048</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120272"&gt;@sayanapex06&lt;/a&gt;: Have you seen &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Recreating-the-code-that-could-have-been-used-to-create-a-format/ta-p/459512" target="_blank"&gt;Chris Hemedinger's recent library article about this topic&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488973#M72048</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-22T16:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488976#M72049</link>
      <description>&lt;P&gt;Started in 1997 - more than 2 decades ago! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488976#M72049</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T16:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488981#M72050</link>
      <description>&lt;P&gt;Not hard the do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  file code ;
  set xxx end=eof ;
  if _n_=1 then put 
 'value $testfr'
  ;
  put @3 cc :$quote. '=' flg :$quote. ;
  if eof then put
   @3 'other="X"'
/ ';'
  ;
run;

proc format ;
  %include code / source2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 17:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488981#M72050</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-22T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488995#M72051</link>
      <description>Yes this is one of the ways we can do.. But I wanna do it with either&lt;BR /&gt;CNTLIN /CNTLOUT&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Aug 2018 18:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488995#M72051</guid>
      <dc:creator>sayanapex06</dc:creator>
      <dc:date>2018-08-22T18:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488998#M72052</link>
      <description>&lt;P&gt;Actually your code looks pretty close.&amp;nbsp; When creating a character format, the name of the format must begin with a dollar sign.&amp;nbsp; I'm not sure that setting the format type to "C" tells SAS to do that automatically.&amp;nbsp; Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;RETAIN FMTNAME '$TESTFR' TYPE 'C' ;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 18:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/488998#M72052</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-22T18:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/489016#M72056</link>
      <description>&lt;P&gt;Did you see&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;post? That seems to do exactly what you want, if it doesn't please explain how.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 19:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/489016#M72056</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T19:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Build a format from a SAS data set and write it to a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/489030#M72058</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120272"&gt;@sayanapex06&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes this is one of the ways we can do.. But I wanna do it with either&lt;BR /&gt;CNTLIN /CNTLOUT&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Like this? I add a record to your starting data set with a missing value for CC to demonstrate that it gets formatted in output as desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA work.XXX ;
LENGTH CC $2. FLG $1. ;
INFILE DATALINES DLM = '~' ;
INPUT @1 CC FLG ;
DATALINES ;
AB~Y
BC~N
CD~Y
DF~N
TY~N
;

DATA work.CREATE_FORMAT ;
RETAIN FMTNAME '$TESTFR' TYPE 'C' ;
SET work.XXX END=EOF ;
START = CC ;
LABEL = FLG ;
OUTPUT ;
IF EOF ; /* ON LAST RECORD */
HLO = 'O' ;
LABEL = 'X' ;
OUTPUT ;
RUN ;

Proc format library=work cntlin=work.create_format;
run;
data work.test;
   set work.xxx end=eof;
   output;
   if eof then do;
      call missing(cc,flg);
      output;
   end;
run;
    
proc print data=work.test;
  var cc;
  format cc $testfr.;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Build-a-format-from-a-SAS-data-set-and-write-it-to-a-text-file/m-p/489030#M72058</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-22T20:06:34Z</dc:date>
    </item>
  </channel>
</rss>

