<?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: Reading a text file but not able to use the custom format in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974068#M46150</link>
    <description>&lt;P&gt;You need an INFORMAT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   invalue $FPROVHF(upcase just default=2)
      'AB','BC','CD'=_same_
      other='OT'
      ;
   quit;

data test;
   input PROVINCE_CD :$FPROVHF.; 
   cards;
XY
AB
XT
BC
;
   run;
proc print;
   run;

/*   NOTE 485-185: Informat $FPROVHF was not found or could not be loaded.*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Sep 2025 18:53:38 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2025-09-03T18:53:38Z</dc:date>
    <item>
      <title>Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974051#M46146</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let env=p;
LIBNAME library "/dwh_actuariat/sasprocess/prodmens/HYFI&amp;amp;env./format";
OPTIONS FMTSEARCH=(LIBRARY.cerform);


%macro readtxtfile(year,month);
filename prd "/dwh_actuariat/sasprocess/prodmens/HYFIp/output/HyFIPrems&amp;amp;year.&amp;amp;month..txt";

data HyFIPrems&amp;amp;year.&amp;amp;month.;

	INFILE PRD LRECL=150 recfm=v;
			INPUT
                    @  1 CIE                      $CHAR1.
				@  2 PROVINCE_CD              $FPROVHF.
				@  6 BRANCH                   $CHAR2.
				@  8 PRIORCUR                 $CHAR1.
				@  9 POLSCR                   $CHAR1.
				@ 10 MOIS                     $CHAR6.
				@ 16 LOB                      $CHAR8.
				@ 24 TRANS                    $CHAR3.
				@ 27 WP                       15.2
				@ 42 EP                       15.2
				@ 57 EU                       15.2
				@ 72 WU                       15.2
				@ 87 NEWREN                   $CHAR1.
				@ 88 POLCNT                   15.2
				@103 POLEARN                  15.2
				@118 UW_CIE                   $CHAR1.
				@119 DIST_CIE                 $CHAR1.
				@120 OB_IND                   $CHAR5.
				@125 broker_group_ind         $CHAR2.
        			@127 GCNA_BRANCH              $CHAR2.
        			@129 POLICY_CATEGORY          $CHAR1.
        			@130 NETWORK_PROVIDER         $CHAR5.
        			@135 AFFINITY_IND             $CHAR1.
				;
		run;

%mend readtxtfile;
%macro hyfiprem;
%do year=2025 %to 2025;
     %do month=01 %to 08;
     %let months= %sysfunc(putn(&amp;amp;month, z2.));
          %put &amp;amp;year.&amp;amp;months.;

          %readtxtfile(&amp;amp;year,&amp;amp;months);

     %end;
%end;
%mend hyfiprem;
%hyfiprem;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;202501&lt;BR /&gt;NOTE: Line generated by the invoked macro "READTXTFILE".&lt;BR /&gt;80 $FPROVHF. @ 6 BRANCH $CHAR2. @ 8 PRIORCUR $CHAR1. @ 9&lt;BR /&gt;_________&lt;BR /&gt;485&lt;BR /&gt;80 ! POLSCR $CHAR1. @ 10 MOIS $CHAR6. @ 16 LOB $CHAR8.&lt;BR /&gt;80 ! @ 24 TRANS&lt;/P&gt;
&lt;P&gt;NOTE 485-185: Informat $FPROVHF was not found or could not be loaded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to solve that issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 16:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974051#M46146</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-09-03T16:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974053#M46147</link>
      <description>&lt;P&gt;Is $FPROVHF a format or an informat? Can you send the results of the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=library.cerform fmtlib;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Sep 2025 16:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974053#M46147</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-09-03T16:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974061#M46148</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alepage_0-1756920720003.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109585i44A1CD9104D6A268/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alepage_0-1756920720003.png" alt="alepage_0-1756920720003.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 17:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974061#M46148</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-09-03T17:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974067#M46149</link>
      <description>&lt;P&gt;What you show is a format; but you reference it on an INPUT statement, so SAS is looking for an Informat with that name.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 18:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974067#M46149</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-09-03T18:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974068#M46150</link>
      <description>&lt;P&gt;You need an INFORMAT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   invalue $FPROVHF(upcase just default=2)
      'AB','BC','CD'=_same_
      other='OT'
      ;
   quit;

data test;
   input PROVINCE_CD :$FPROVHF.; 
   cards;
XY
AB
XT
BC
;
   run;
proc print;
   run;

/*   NOTE 485-185: Informat $FPROVHF was not found or could not be loaded.*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 18:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974068#M46150</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-09-03T18:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974088#M46151</link>
      <description>&lt;P&gt;Remember that FORMATs convert values into text.&lt;/P&gt;
&lt;P&gt;To convert text into values you need an INFORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So define the &lt;STRONG&gt;INFORMAT&lt;/STRONG&gt; named&amp;nbsp;$FPROVHF before trying to use it to create the character variable&amp;nbsp;PROVINCE_CD by reading the values starting at column 2 of your text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure the default width is not longer than 4 or it might try to "eat" the values of BRANCH from columns 6 and beyond.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you want to use a custom INFORMAT to read in the values?&amp;nbsp; Wouldn't it be better to just read in the values using the normal $ informat that would not try to modify them and then attach a FORMAT to the variable so it is displayed the way you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what is with the use of the $CHAR informat for the other character variables? That will do two silly things.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For longer fields like&amp;nbsp;NETWORK_PROVIDER $CHAR5. it will preserve any leading spaces.&amp;nbsp; Which can cause confusion because the value 'BC' will not not match '&amp;nbsp; &amp;nbsp;BC', even if ODS outputs (like HTML) will make them appear the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And $CHAR will treat a value consisting of just a single period as a normal period, instead of translating it into spaces as the normal $ informat would.&amp;nbsp; The reason the $ informat does that is so you can use a period to indicate a missing (empty) value for both the numeric and the character variables.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Sep 2025 02:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974088#M46151</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-04T02:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file but not able to use the custom format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974324#M46153</link>
      <description>&lt;P&gt;You can use Proc Format to tell you about the custom formats/informats you have available.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example that creates one format and one informat in the Work library and default format catalog. Then&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gets the descriptions with the FMTLIB option. Run the below code and see in the description the the $ABC has the words FORMAT NAME, indicating it is an output format and $PDQ has INFORMAT NAME indicating it is used for reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would want to use Library=LIBRARY.cerform in the Proc format statement to examine you custom formats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* create a custom format to use later*/

proc format ;
value $abc
'abc'='some formatted result'
;
invalue $pdq
'pdq'='input result value'
;
run;
/* get descriptions of the current custom format/informats */
proc format library=work fmtlib;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I would quite often have an informat/format pair defined because the INVALUE has different options available such as &amp;lt;some value description&amp;gt; = _error_ to report in the log that the value encountered may not be valid and reports as such in the log, or to create special missing values that a FORMAT could then provide details about when requested. Plus for reading text the INVALUE option UPCASE is very helpful to standardize values so that Abc, ABc, aBc, abC (etc) are all read into the value ABC.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Sep 2025 13:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-but-not-able-to-use-the-custom-format/m-p/974324#M46153</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-09-06T13:27:20Z</dc:date>
    </item>
  </channel>
</rss>

