<?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: Proc Format: Using keywords in control input tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755933#M238594</link>
    <description>&lt;P&gt;Once you digest Reeza's explanation, it is possible you just need to add a single statement to your DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start="low" then HLO = "L";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When HLO is set to "L", SAS ignores the value of START and assumes that you want to use the lowest undefined value as the beginning of your range.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jul 2021 13:24:49 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-07-22T13:24:49Z</dc:date>
    <item>
      <title>Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755815#M238577</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm trying to use proc format to read in a table using the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
	length Start $8  End $8 Label $15;
	retain fmtName "testStormFormat" type "n";
	input Start $ End $ Label $;
	infile datalines dlm = ",";
	datalines;
	low,63,No Category
	64,82,Category 1 
	83,95,Category 2 	
	96,112,Category 3 	
	113,136,Category 4 
	137,high,Category 5
	;
	run;

proc format cntlIn = test_storm_categories;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But, I'm getting the following error:&lt;/P&gt;&lt;PRE&gt;ERROR: Cannot mix missing and nonmissing values in the same range: .-63.&lt;/PRE&gt;&lt;P&gt;Can someone explain to me why 'low' isn't being read as a keyword here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;kelbrosna&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. Here are some more details:&lt;/P&gt;&lt;P&gt;1. Version number (per proc setinit) is&amp;nbsp;&lt;SPAN&gt;9.04.01M6P110718, and I'm using SAS Studio.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. I'm aware that you can specify keywords for ranges using an 'HLO' column, and that fix works for me. I don't need this code to work, I'm just curious why it fails.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. This code is based on an exercise from the&amp;nbsp;&lt;U&gt;SAS Programming 2: Data Manipulation Techniques&lt;/U&gt; course notes&amp;nbsp;(Lesson 4.2, page 4-20 step 2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a. The exercise uses a premade table (storm_categories.sas7bdat) from the course data (which I would include, but I don't think I'm allowed to share it), and I also read in that table using the following code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data storm_categories;
	set pg2.storm_categories (rename=
	(Low = Start High = End Category = Label));
	retain fmtName "stormFormat";
	run;

proc format cntlIn = storm_categories;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code runs as expected, and it does not give any errors. What's perplexing about this is that the test_storm_categories dataset from the datalines statement in the original code is seemingly identical to this storm_categories dataset, but their behavior is different.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; b. When I export and re-import the&amp;nbsp;&lt;SPAN&gt;storm_categories.sas7bdat table as a CSV file (using proc export and proc import), then perform the necessary operations and feed it to proc format, I get the same error as that from test_storm_categories. This makes me think that there may be some kind of hidden metadata in the&amp;nbsp;storm_categories.sas7bdat table that matters. Is that a possibility?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. The reason why I think the 'low' keyword is being misread is because when changed to a number, e.g. 40, no error is raised. However, the 'high' keyword doesn't raise any error, even when left unchanged. My current understanding of what is happening is that the character string "low" is being read as a missing numeric value, but I'm not sure why this is.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 01:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755815#M238577</guid>
      <dc:creator>kelbrosna</dc:creator>
      <dc:date>2021-07-22T01:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755817#M238578</link>
      <description>&lt;P&gt;High/Low keyword require the HLO flag set. Because you could have a value of High/Low you wanted to recode as well, in fact those are common in informants/formats so you need to tell SAS to not interpret it as value but as the keyword, which you do via the HLO flag.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One quick way I test questions like this is to generate the format manually and then pipe the format to a CNTLOUT dataset and check the data set it creates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value testStormFormat
low - 63 = "No Category"
64 - 82 = "Category 1"
83 - 95 = "Category 2"
96 - 112 = "Category 3"
112 - 136 = "Category 4"
137 - High = "Category 5";
run;

proc format cntlout=demo;
select testStormFormat;
run;

proc print data=demo;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regarding 3B -&amp;gt; Since you're not sharing the code from the storm program I cannot comment on that but I'm guessing it does set the HLO flag somewhere.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0owa4ftikc2ekn1q0rmpulg86cx.htm" target="_self"&gt;documentation&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;If you specify &lt;CODE class="xisDoc-inlineCode"&gt;START='LOW'&lt;/CODE&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;, and the HLO variable does not contain 'L', then the literal value of LOW is used.&lt;/STRONG&gt; If you specify &lt;/SPAN&gt;&lt;CODE class="xisDoc-inlineCode"&gt;START='OTHER'&lt;/CODE&gt;&lt;SPAN&gt;, and the HLO variable does not contain 'O', then the literal value of OTHER is used. If you specify &lt;/SPAN&gt;&lt;CODE class="xisDoc-inlineCode"&gt;END='HIGH'&lt;/CODE&gt;&lt;SPAN&gt;, and the HLO variable does not contain 'H', then the literal value of HIGH is used.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/384763"&gt;@kelbrosna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm trying to use proc format to read in a table using the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
	length Start $8  End $8 Label $15;
	retain fmtName "testStormFormat" type "n";
	input Start $ End $ Label $;
	infile datalines dlm = ",";
	datalines;
	low,63,No Category
	64,82,Category 1 
	83,95,Category 2 	
	96,112,Category 3 	
	113,136,Category 4 
	137,high,Category 5
	;
	run;

proc format cntlIn = test_storm_categories;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But, I'm getting the following error:&lt;/P&gt;
&lt;PRE&gt;ERROR: Cannot mix missing and nonmissing values in the same range: .-63.&lt;/PRE&gt;
&lt;P&gt;Can someone explain to me why 'low' isn't being read as a keyword here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;kelbrosna&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Here are some more details:&lt;/P&gt;
&lt;P&gt;1. Version number (per proc setinit) is&amp;nbsp;&lt;SPAN&gt;9.04.01M6P110718, and I'm using SAS Studio.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. I'm aware that you can specify keywords for ranges using an 'HLO' column, and that fix works for me. I don't need this code to work, I'm just curious why it fails.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. This code is based on an exercise from the&amp;nbsp;&lt;U&gt;SAS Programming 2: Data Manipulation Techniques&lt;/U&gt; course notes&amp;nbsp;(Lesson 4.2, page 4-20 step 2).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a. The exercise uses a premade table (storm_categories.sas7bdat) from the course data (which I would include, but I don't think I'm allowed to share it), and I also read in that table using the following code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data storm_categories;
	set pg2.storm_categories (rename=
	(Low = Start High = End Category = Label));
	retain fmtName "stormFormat";
	run;

proc format cntlIn = storm_categories;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code runs as expected, and it does not give any errors. What's perplexing about this is that the test_storm_categories dataset from the datalines statement in the original code is seemingly identical to this storm_categories dataset, but their behavior is different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; b. When I export and re-import the&amp;nbsp;&lt;SPAN&gt;storm_categories.sas7bdat table as a CSV file (using proc export and proc import), then perform the necessary operations and feed it to proc format, I get the same error as that from test_storm_categories. This makes me think that there may be some kind of hidden metadata in the&amp;nbsp;storm_categories.sas7bdat table that matters. Is that a possibility?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4. The reason why I think the 'low' keyword is being misread is because when changed to a number, e.g. 40, no error is raised. However, the 'high' keyword doesn't raise any error, even when left unchanged. My current understanding of what is happening is that the character string "low" is being read as a missing numeric value, but I'm not sure why this is.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Thu, 22 Jul 2021 02:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755817#M238578</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-22T02:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755819#M238579</link>
      <description>FYI - if you're paying for the course you can ask SAS about 3a/b. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jul 2021 02:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755819#M238579</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-22T02:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755933#M238594</link>
      <description>&lt;P&gt;Once you digest Reeza's explanation, it is possible you just need to add a single statement to your DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start="low" then HLO = "L";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When HLO is set to "L", SAS ignores the value of START and assumes that you want to use the lowest undefined value as the beginning of your range.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 13:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/755933#M238594</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-07-22T13:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756086#M238662</link>
      <description>&lt;P&gt;From the documentation:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"If you are creating a format with the CNTLIN= option, &lt;STRONG&gt;the&lt;/STRONG&gt; &lt;STRONG&gt;value of LOW or OTHER for the START variable and the value of HIGH for the END variable are interpreted as their corresponding keywords of LOW, OTHER, or HIGH&lt;/STRONG&gt;. This interpretation occurs whether you specify the values in uppercase or lowercase. &lt;STRONG&gt;If you want the explicit values of LOW, OTHER, or HIGH to be used, then specify the HLO variable with the values as described below.&lt;/STRONG&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Based on the wording, i&lt;/SPAN&gt;&lt;SPAN&gt;f there is no HLO variable in the CNTLIN table, shouldn't SAS be expected to interpret "low" and "high" as keywords? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Based on the error in the original post, it seems that "low" is being interpreted as the literal value "low". However, as mentioned in part 4, when the value "low" is changed to 40 in the input table, SAS seems to interpret "high" as a keyword, as shown by the code below:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
	length Start $8  End $8 Label $15;
	retain fmtName "testStormFormat" type "n";
	input Start $ End $ Label $;
	infile datalines dlm = ",";
	datalines;
	40,63,No Category
	64,82,Category 1 
	83,95,Category 2 	
	96,112,Category 3 	
	113,136,Category 4 
	137,high,Category 5
	;
	run;

proc format cntlIn = test_storm_categories fmtlib;
	select testStormFormat;
	run;
	
proc format cntlOut = demo;
	select testStormFormat;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;The CNTLOUT table's HLO column correctly assigns a value of "H" for the row with "high". Is there any particular reason why "high" and "low" should be interpreted differently by SAS?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 22:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756086#M238662</guid>
      <dc:creator>kelbrosna</dc:creator>
      <dc:date>2021-07-22T22:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756091#M238665</link>
      <description>The paragraph is a bit ambiguous, and the paragraph that follows contradicts that...and the SAS behaviour aligns with the second paragraph.</description>
      <pubDate>Thu, 22 Jul 2021 22:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756091#M238665</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-22T22:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756092#M238666</link>
      <description>And there's always a HLO value in the data set, SAS creates it automatically and it's blank.</description>
      <pubDate>Thu, 22 Jul 2021 22:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756092#M238666</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-22T22:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756108#M238670</link>
      <description>&lt;P&gt;Two questions:&lt;/P&gt;&lt;P&gt;1. Is there a way to get SAS to display hidden columns?&lt;/P&gt;&lt;P&gt;2. If the HLO column is blank, why does "high" get interpreted as a keyword?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 03:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756108#M238670</guid>
      <dc:creator>kelbrosna</dc:creator>
      <dc:date>2021-07-23T03:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756221#M238717</link>
      <description>As mentioned previously, CNTLOUT. For your second question read the paragraph exactly AFTER the one you posted initially that describes how to set HIGH as a literal value, ie if you had HIGH, LOW, MEDIUM as text values and wanted to recode those to 1, 2, 3 via a format, how would you pass those values to SAS?&lt;BR /&gt;&lt;BR /&gt;proc format cntlout=mydata;&lt;BR /&gt;select formatName;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 23 Jul 2021 14:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756221#M238717</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-23T14:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756226#M238721</link>
      <description>FROM the documentation as well: If you specify END='HIGH', and the HLO variable does not contain 'H', then the literal value of HIGH is used.&lt;BR /&gt;&lt;BR /&gt;Blanks are not H.</description>
      <pubDate>Fri, 23 Jul 2021 14:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/756226#M238721</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-23T14:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757591#M239155</link>
      <description>&lt;P&gt;From my previous reply:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
	length Start $8  End $8 Label $15;
	retain fmtName "testStormFormat" type "n";
	input Start $ End $ Label $;
	infile datalines dlm = ",";
	datalines;
	40,63,No Category
	64,82,Category 1 
	83,95,Category 2 	
	96,112,Category 3 	
	113,136,Category 4 
	137,high,Category 5
	;
	run;

proc format cntlIn = test_storm_categories fmtlib;
	select testStormFormat;
	run;
	
proc format cntlOut = demo;
	select testStormFormat;
	run;

proc print data = demo;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running this code, we get a valid format, and the auto-generated HLO column has the value "H" in the row where the END column had value "high". Based on what you said above, the auto-generated HLO column should be blank. The fact that this code generates an HLO column with a non-blank entry seems to contradict that claim.&lt;/P&gt;&lt;P&gt;When you run the above code, do you get a different result?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 05:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757591#M239155</guid>
      <dc:creator>kelbrosna</dc:creator>
      <dc:date>2021-07-28T05:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757708#M239203</link>
      <description>Open a ticket with SAS tech support.</description>
      <pubDate>Wed, 28 Jul 2021 14:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757708#M239203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T14:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757735#M239211</link>
      <description>&lt;P&gt;If you don't want it to interpret 'high' as meaning HIGH then you would need to create an character format instead of a numeric format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to make a valid CNTLIN dataset that is clearer to you and more closely matches the CNTLOUT dataset then include the HLO variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
  retain fmtName "testStormFormat" type "n" ;
  input Start $ End $ Label $15.;
  length hlo $3;
  if start='other' then do; hlo='O'; start=' '; end=' '; end;
  if start='low' then do; hlo='L'; start=' '; end;
  if end='high' then do; hlo=cats(hlo,'H'); end=' '; end;
datalines;
40 63 No Category
64 82 Category 1
83 95 Category 2
96 112 Category 3
113 136 Category 4
137 high Category 5
other . Invalid number
;

proc format cntlIn = test_storm_categories fmtlib cntlout=demo;
  select testStormFormat;
run;

proc print data=demo;
  var fmtname type start end hlo label;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;DEMO output&lt;/P&gt;
&lt;PRE&gt;Obs        FMTNAME        TYPE         START                END           HLO        LABEL

 1     TESTSTORMFORMAT     N                    40                  63           No Category
 2     TESTSTORMFORMAT     N                    64                  82           Category 1
 3     TESTSTORMFORMAT     N                    83                  95           Category 2
 4     TESTSTORMFORMAT     N                    96                 112           Category 3
 5     TESTSTORMFORMAT     N                   113                 136           Category 4
 6     TESTSTORMFORMAT     N                   137    HIGH                 H     Category 5
 7     TESTSTORMFORMAT     N      **OTHER**           **OTHER**            O     Invalid number
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757735#M239211</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T15:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757736#M239212</link>
      <description>High seems to work correctly, but Low does not - see first set of code ergo my recommendation to talk to Tech Support now. &lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757736#M239212</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T15:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757747#M239213</link>
      <description>&lt;P&gt;Low and OTHER seem to work fine for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
  retain fmtName "testStormFormat" type "n" ;
  input Start $ End $ Label $15.;
datalines;
low 63 No Category
64 82 Category 1
83 95 Category 2
96 112 Category 3
113 136 Category 4
137 high Category 5
other . Invalid number
;

proc format cntlIn = test_storm_categories fmtlib cntlout=demo;
  select testStormFormat;
run;

proc print data=demo;
  var fmtname type start end hlo label;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757747#M239213</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T15:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757755#M239215</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/384763"&gt;@kelbrosna&lt;/a&gt;&amp;nbsp; So your initial code doesn't work because you have leading spaces in front of the word low, so SAS isn't recognizing it as low. If you trim the field it works fine. Leading spaces don't show in the table view which makes this one a bit harder to spot initially.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_storm_categories;
	length Start $8  End $8 Label $15;
	retain fmtName "testStormFormat" type "n";
	input Start $ End $ Label $;
	start = trim(start);
	infile datalines dlm = ",";
	datalines;
low,63,No Category
64,82,Category 1 
83,95,Category 2 	
96,112,Category 3 	
113,136,Category 4 
137,high,Category 5
	;
	run;
	
	proc format cntlin = test_storm_categories;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for the help with the issue resolution&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757755#M239215</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757768#M239221</link>
      <description>&lt;P&gt;So the interaction of all of the mistakes in that data step is what lead to the inclusion of leading spaces into the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) Not starting the DATALINES line in column 1.&lt;/P&gt;
&lt;P&gt;2) Not starting the actual data lines in column 1.&lt;/P&gt;
&lt;P&gt;3) And finally not using the DSD option when using a delimiter other than space.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757768#M239221</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T15:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757891#M239262</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Is there a way to tell SAS to trim leading and trailing blanks within datalines? Also, I originally switched to comma-delimited columns because I wasn't sure how to include a space in a column value when spaces are delimiters. Is there some kind of escape character in SAS (to tell SAS to read a space as a literal value, not a delimiter)?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;kelbrosna&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 19:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757891#M239262</guid>
      <dc:creator>kelbrosna</dc:creator>
      <dc:date>2021-07-28T19:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757904#M239270</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/384763"&gt;@kelbrosna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Is there a way to tell SAS to trim leading and trailing blanks within datalines? Also, I originally switched to comma-delimited columns because I wasn't sure how to include a space in a column value when spaces are delimiters. Is there some kind of escape character in SAS (to tell SAS to read a space as a literal value, not a delimiter)?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;kelbrosna&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read the manual pages on INPUT statement.&amp;nbsp; In particular check out the LIST MODE input method, which is what your code was using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In list mode SAS reads variable length "words" from a line.&amp;nbsp; The default delimiter is a space and multiple spaces are treated the same as one.&amp;nbsp; This is great when the spaces have been added just to make the columns look neat on your punch card (or on your screen when using a fixed space font).&amp;nbsp; You can use the&amp;nbsp; &amp;amp; modify to tell SAS that it should require two or more consecutive spaces to mark the end of a "word".&amp;nbsp; &amp;nbsp;So use by adding that extra space between the variable values you can allow for embedded single spaces.&amp;nbsp; That would work well for your example.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length start end $8 label $15;
  input Start End Label &amp;amp; ;
datalines;
low      0 Negative value
    0   63 No Category
   64   82 Category 1
   83   95 Category 2
   96  112 Category 3
  113  136 Category 4
  137 high Category 5
other    . Invalid number
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other thing to notice is that last line of data.&amp;nbsp; Since there is no value for END a period is used to represent a missing value.&amp;nbsp; The regular $ informat (what SAS users be default for character variables) will convert the period to an empty (all spaces) value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp; DSD option allows SAS to use a delimited text line instead.&amp;nbsp; Each value is separated from the other values by the delimiter. Two delimiters next to each other indicate a missing value.&amp;nbsp; If you need to include the delimiter in the value then enclose the value in quotes.&amp;nbsp; &amp;nbsp;If you need to include a quote in the value then enclose the value in quotes and double up the quotes in the value.&amp;nbsp; (Note that SAS will also allow you to use either double or single quotes on the outside although most consumers of such files only allow double quote characters.)&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length start end $8 label $15;
  infile datalines dsd truncover ;
  input Start End Label  ;
datalines;
0,1,"Zero,One"
other,,Unknown
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 19:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757904#M239270</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T19:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format: Using keywords in control input tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757919#M239275</link>
      <description>IME It is very rare to read anything from datalines except in tutorials/examples. For control tables, we use either SharePoint Lists or controlled forms and you read from a DB, or sometimes CSV files but very rarely datalines/cards are used.</description>
      <pubDate>Wed, 28 Jul 2021 19:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-Using-keywords-in-control-input-tables/m-p/757919#M239275</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-28T19:49:26Z</dc:date>
    </item>
  </channel>
</rss>

