<?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: Why I have missed one format - when I am adding another category (or updating) my formats? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267664#M52920</link>
    <description>&lt;P&gt;Also, please someone define what is HLO variable. Is its name and role is fixed?&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, when and how we can use its High and Low (values/ options)?&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2016 16:32:17 GMT</pubDate>
    <dc:creator>AG_Stats</dc:creator>
    <dc:date>2016-05-02T16:32:17Z</dc:date>
    <item>
      <title>Why I have missed one format - when I am adding another category (or updating) my formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267660#M52918</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please go through the following codes and reply accordingly (I have stated my problem in it).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname learn '/folders/myfolders/sas';

*-----------------------------------------------------------------------------------*
 Creating a test data set that will be used to make a CNTLIN data set
*-----------------------------------------------------------------------------------*;
data learn.codes;
	input ICD9 : $5. Description &amp;amp; $21.;
datalines;
020 Plague
022 Anthrax
390 Rheumatic fever
410 Myocardial infarction
493 Asthma
540 Appendicitis
;

*----------------------------------------------------------------------*
 Creating a CNTLIN data set from an existing SAS data set
*----------------------------------------------------------------------*;
data control;
	set learn.codes(rename= (ICD9 = Start Description = Label));
	retain Fmtname '$ICDFMT' Type 'C';
run;
title "Demonstrating an Input Control Data Set";
proc format cntlin=control fmtlib;
run;

*------------------------------------------------*
 Using the CNTLIN= created data set
*------------------------------------------------*;
data disease;
	input ICD9 : $5. @@;
datalines;
020 410 500 493
;
title "Listing of DISEASE";
proc print data=disease noobs;
	format ICD9 $ICDFMT.;
run;

*-----------------------------------------------------*
 Adding an OTHER category to your format
*-----------------------------------------------------*;
proc delete data=control;
data control;
	set learn.codes(rename= (ICD9 = Start Description = Label)) end = last;
	
	retain Fmtname '$ICDFMT' Type 'C';
	
	if last then do;
		Start = ' ';
		Hlo = 'o';
		Label = 'Not Found';
	end;
run;

/* 
Why from here (from last code) we have lost one (exactly last) format / Label viz. for code 540 Appendicitis?

It may be because of using if last then do; 

If it is so then please anyone give me an alternate way i.e. codes (simple &amp;amp; small if  possible) to achieve the same goal without missing last format

You can also see that this particular code 540 Appendicitis is missing for all remaining program.
*/


proc format cntlin=control fmtlib;
run; /* Note: Remember to run proc format again */

data disease;
	input ICD9 : $5. @@;
datalines;
020 410 500 493
;
title "Listing of DISEASE";
proc print data=disease noobs;
	format ICD9 $ICDFMT.;
run;


*--------------------------------------------------------------------------*
 Updating an existing format using a CNTLOUT=data set option 
*--------------------------------------------------------------------------*;

proc format cntlout=control_out;
	select $ICDFMT;
run;

data new_control;
	length Label $ 21;
	
	set control_out end=Last;
	output;

	if Last then
		do;
			Hlo=' ';
			
			Start='427.5';
			End=Start;
			Label='Cardiac Arrest';
			output;
			
			Start='466';
			End=Start;
			Label='Bronchitis';
			output;
		end;
run;

proc format cntlin=new_control;
	select $ICDFMT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 16:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267660#M52918</guid>
      <dc:creator>AG_Stats</dc:creator>
      <dc:date>2016-05-02T16:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why I have missed one format - when I am adding another category (or updating) my formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267664#M52920</link>
      <description>&lt;P&gt;Also, please someone define what is HLO variable. Is its name and role is fixed?&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, when and how we can use its High and Low (values/ options)?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267664#M52920</guid>
      <dc:creator>AG_Stats</dc:creator>
      <dc:date>2016-05-02T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why I have missed one format - when I am adding another category (or updating) my formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267665#M52921</link>
      <description>&lt;P&gt;You overwrote the last value with blanks. &amp;nbsp;Add OUTPUT statements like in your last example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data control;
  set learn.codes(rename= (ICD9 = Start Description = Label)) end = last;
  retain Fmtname '$ICDFMT' Type 'C';
  output ;	*&amp;lt;-- ADD ;
  if last then do;
    Start = ' ';
    Hlo = 'o';
    Label = 'Not Found';
    output; *&amp;lt;-- ADD ;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267665#M52921</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-02T16:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why I have missed one format - when I am adding another category (or updating) my formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267666#M52922</link>
      <description>&lt;P&gt;Make some formats with different combinations of included upper and lower bounds and other categories and generate the CNTLOUT dataset and examine it carefully to see the patterns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or just read the manual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;HLO
specifies a character variable that contains range information about the format or informat. 
The following valid values can appear in any combination:
F specifies a standard SAS format or informat that is used with a value.
H specifies that a range's ending value is HIGH.
I specifies a numeric informat range.
J specifies justification for an informat.
L specifies that a range's starting value is LOW.
M specifies that the MULTILABEL option is in effect.
N specifies that the format or informat has no ranges, including no OTHER= range.
O specifies that the range is OTHER.
R specifies that the ROUND option is in effect.
S specifies that the NOTSORTED option is in effect.
U specifies that the UPCASE option for an informat be used.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-I-have-missed-one-format-when-I-am-adding-another-category/m-p/267666#M52922</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-02T16:43:47Z</dc:date>
    </item>
  </channel>
</rss>

