<?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: Help need in using compress function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760483#M240484</link>
    <description>&lt;P&gt;You've got the right idea using the COMPRESS function with 'kd' as the third parameter.&amp;nbsp; Then you would want to use the INPUT function (function not statement) to cast the data into numeric form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a $20.;
datalines;
CYCLE 15 DAY 22
CYCLE 33 DAY 22
;
data want;
	set have;
	b	=	INPUT(TRANWRD(strip(COMPBL(compress(a,,'kd'))),' ', '.'), 8.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which yields:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1628546588416.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62422iCE33BB6E405A6DC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1628546588416.png" alt="jimbarbour_0-1628546588416.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that's what you want?&amp;nbsp; It almost seems like cycle and day should be two separate fields instead of a single numeric fields with two values, in essence, separated by a decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Mon, 09 Aug 2021 22:04:25 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2021-08-09T22:04:25Z</dc:date>
    <item>
      <title>Help need in using compress function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760482#M240483</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;I need help in my pgm to get the output i need. I need to create a numeric variable &lt;FONT color="#FF6600"&gt;'b'&lt;/FONT&gt;&amp;nbsp; from char variable&amp;nbsp;&lt;FONT color="#FF6600"&gt; 'a'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output need&lt;/P&gt;
&lt;P&gt;15.22&lt;/P&gt;
&lt;P&gt;33.22&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please suggest. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a $20.;
datalines;
CYCLE 15 DAY 22
CYCLE 33 DAY 22
;
data want;
set have;
b=compress(a,'','kd');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Aug 2021 21:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760482#M240483</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2021-08-09T21:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help need in using compress function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760483#M240484</link>
      <description>&lt;P&gt;You've got the right idea using the COMPRESS function with 'kd' as the third parameter.&amp;nbsp; Then you would want to use the INPUT function (function not statement) to cast the data into numeric form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a $20.;
datalines;
CYCLE 15 DAY 22
CYCLE 33 DAY 22
;
data want;
	set have;
	b	=	INPUT(TRANWRD(strip(COMPBL(compress(a,,'kd'))),' ', '.'), 8.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which yields:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1628546588416.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62422iCE33BB6E405A6DC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1628546588416.png" alt="jimbarbour_0-1628546588416.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that's what you want?&amp;nbsp; It almost seems like cycle and day should be two separate fields instead of a single numeric fields with two values, in essence, separated by a decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 22:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760483#M240484</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-09T22:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help need in using compress function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760487#M240485</link>
      <description>&lt;P&gt;I suspect you really want two variables, CYCLE and DAY, and likely separately. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CYCLE = input(scan(a, 2), 8.);
DAY = input(scan(a, 4), 8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68272"&gt;@knveraraju91&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;I need help in my pgm to get the output i need. I need to create a numeric variable &lt;FONT color="#FF6600"&gt;'b'&lt;/FONT&gt;&amp;nbsp; from char variable&amp;nbsp;&lt;FONT color="#FF6600"&gt; 'a'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output need&lt;/P&gt;
&lt;P&gt;15.22&lt;/P&gt;
&lt;P&gt;33.22&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please suggest. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a $20.;
datalines;
CYCLE 15 DAY 22
CYCLE 33 DAY 22
;
data want;
set have;
b=compress(a,'','kd');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 22:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760487#M240485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-09T22:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help need in using compress function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760630#M240528</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a $20.;
datalines;
CYCLE 15 DAY 22
CYCLE 33 DAY 22
;
data want;
set have;
b=catx('.',scan(a,1,,'kd'),scan(a,2,,'kd'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Aug 2021 13:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-need-in-using-compress-function/m-p/760630#M240528</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-10T13:14:28Z</dc:date>
    </item>
  </channel>
</rss>

