<?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: SAS Newbie Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619318#M181794</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Data two; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;length&amp;nbsp;Battalion $6;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set 1; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If greenberet1 &amp;lt; 40 then ...&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2020 20:48:28 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-01-22T20:48:28Z</dc:date>
    <item>
      <title>Why is this string value truncated?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619101#M181706</link>
      <description>&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm trying to input some data into a table that is devided up into 3 different categories: Small, medium and large.&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;The problem is when I run/submit the code, I have only the word "Mediu" instead of "medium" pop up in my categories box of my table.&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;What do I need to do for the word "medium" to appear on my table?&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm currently running:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data two;
 Set 1;
 If greenberet1 &amp;lt; 40 then Battalion='Small';
 Else if greenberet1 &amp;lt; 100 then Battalion = 'Medium';
 Else Battalion = 'Large'; 
Run; 

Proc freq; Tables Battalion*Advanced; Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619101#M181706</guid>
      <dc:creator>IvanDiego</dc:creator>
      <dc:date>2020-01-22T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Newbie Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619318#M181794</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Data two; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;length&amp;nbsp;Battalion $6;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set 1; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If greenberet1 &amp;lt; 40 then ...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 20:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619318#M181794</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-22T20:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Newbie Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619324#M181797</link>
      <description>Please change the title of your post to something meaningful, such as: Why is this string value truncated?</description>
      <pubDate>Wed, 22 Jan 2020 21:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619324#M181797</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-01-22T21:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Newbie Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619327#M181798</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/308353"&gt;@IvanDiego&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm trying to input some data into a table that is devided up into 3 different categories: Small, medium and large.&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;The problem is when I run/submit the code, I have only the word "Mediu" instead of "medium" pop up in my categories box of my table.&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;What do I need to do for the word "medium" to appear on my table?&lt;/P&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm currently running: Data two; Set 1; If greenberet1 &amp;lt; 40 then Battalion='Small'; Else if greenberet1 &amp;lt; 100 then Battalion = 'Medium'; Else Battalion = 'Large'; Run; Proc freq; Tables Battalion*Advanced; Run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may also want to consider custom formats such as:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value greenberet
0  -&amp;lt; 40 = 'Small'
40 -&amp;lt;100 = 'Medium'
100- high= 'Large'
;

proc freq data=one;
   tables greenberet1*advanced;
   format greenberet1 greenberet. ;
run;&lt;/PRE&gt;
&lt;P&gt;When a display value depends on a single variable, in this case Greenberet1, a format is often a good choice.&lt;/P&gt;
&lt;P&gt;Reasons: The logic code is removed from a data step which in the case of multiple groups (following in some of your vocabulary think: fire team, squad, platoon, company, battalion, regiment, brigade, division, corps if you wanted a single number of men to be an equivalent that is bit more code).&lt;/P&gt;
&lt;P&gt;Second if you decide that you need to have a different grouping for some purpose you can create a different format, or modify the code for the existing format, and the report, analysis or graphing procedure will use the groups created by the format without having to add yet another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changing the format to:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value greenberet
0  -&amp;lt; 50 = 'Small'
50 -&amp;lt;100 = 'Medium'
100- high= 'Large'
;
run;

proc freq data=one;
   tables greenberet1*advanced;
   format greenberet1 greenberet. ;
run;&lt;/PRE&gt;
&lt;P&gt;will get a different result and no changes to the data set are needed OR the Proc Freq code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be default the entire&amp;nbsp;text label associated with the format will be displayed. But you could modify that by specifying a different display length such as&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; greenberet1 &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;greenberet1.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; ; displays one character from the format: S, M or L&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; greenberet1 &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;greenberet3.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; ; displays three characters from the format: Sma Med Lar&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The ability to specify the display width is why you can't use a digit as the last character in a format name (the Value statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some data that reports on more than 15 different age groups. I really don't want to keep track of that many different variables that are similar. Plus I never know when one of my users wants to see "what happens if we shift the age boundary from 17 to 19".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have to make sure the format is available when needed though by either running the format code in each session or placing the format in a location your SAS system FMTSEARCH option sets for finding formats.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619327#M181798</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-22T21:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this string value truncated?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619333#M181803</link>
      <description>&lt;P&gt;Since you never defined BATTALION SAS had to guess how you wanted it defined based on how you first used it.&lt;/P&gt;
&lt;P&gt;Since the first usage is setting it to a five character string it defined the variable to have length of 5.&lt;/P&gt;
&lt;P&gt;Define the variable before giving it values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length battalion $8;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or make sure that the first place you use it in the code you is in a way that SAS will create it with a length that is as long or longer than any value you want it to hold.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; If greenberet1 &amp;lt; 40 then Battalion='Small         ';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-this-string-value-truncated/m-p/619333#M181803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-22T21:48:20Z</dc:date>
    </item>
  </channel>
</rss>

