<?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 Find and Compress function difficulty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396482#M95728</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning about find and compress functions. There is a variable called weight in a set learn.study. That variable has weights in both Kgs and lbs. I want to convert all the weights into pounds, and make it numeric. I have tried doing this, but get an error, and I am not sure what is wrong. Any help would be appreciated. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname Learn '/folders/myfolders/Learn' ;&lt;BR /&gt;&lt;BR /&gt;Data Prob12_8 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set learn.study(rename = (Weight = WeightTemp)) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If find(weighttemp, kg, 'i') then weight = 2.2*input(compress(Weighttemp,,'kd', 8. ));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if find(weighttemp, lbs, 'i') then weight = input(compress(Weighttemp,,'kd', 8. )) ;&lt;BR /&gt;&lt;BR /&gt;proc print data=Prob12_8 noobs ;&lt;BR /&gt;run ;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Sep 2017 20:44:08 GMT</pubDate>
    <dc:creator>ManitobaMoose</dc:creator>
    <dc:date>2017-09-15T20:44:08Z</dc:date>
    <item>
      <title>Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396482#M95728</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning about find and compress functions. There is a variable called weight in a set learn.study. That variable has weights in both Kgs and lbs. I want to convert all the weights into pounds, and make it numeric. I have tried doing this, but get an error, and I am not sure what is wrong. Any help would be appreciated. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname Learn '/folders/myfolders/Learn' ;&lt;BR /&gt;&lt;BR /&gt;Data Prob12_8 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set learn.study(rename = (Weight = WeightTemp)) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If find(weighttemp, kg, 'i') then weight = 2.2*input(compress(Weighttemp,,'kd', 8. ));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if find(weighttemp, lbs, 'i') then weight = input(compress(Weighttemp,,'kd', 8. )) ;&lt;BR /&gt;&lt;BR /&gt;proc print data=Prob12_8 noobs ;&lt;BR /&gt;run ;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 20:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396482#M95728</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-15T20:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396485#M95731</link>
      <description>&lt;P&gt;Just a general principle at work ... in a DATA step, you need quotes to indicate that a set of characters is a character string and not a reference to a variable. &amp;nbsp;Add quotes around "lbs" and "kg".&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 20:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396485#M95731</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-15T20:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396492#M95736</link>
      <description>&lt;P&gt;Thanks for that suggestion. I have corrected that. However, I am still getting this error in the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;libname Learn '/folders/myfolders/Learn' ;&lt;BR /&gt;&lt;BR /&gt;Data Prob12_8 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set learn.study(rename = (Weight = WeightTemp)) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If find(weighttemp, 'kg', 'i') then weight = 2.2*input(compress(Weighttemp,,'kd', 8. ));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if find(weighttemp, 'lbs', 'i') then weight = input(compress(Weighttemp,,'kd', 8. )) ;&lt;BR /&gt;&lt;BR /&gt;proc print data=Prob12_8 noobs ;&lt;BR /&gt;run ;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 21:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396492#M95736</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-15T21:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396498#M95741</link>
      <description>&lt;P&gt;When you get an error post the code and error message from log. Paste it into a codebox opened using the forum {i} menu icon to preserve formatting as the main message windows reformat text and will move the indicator, an _ , that appears at the offending postion in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am pretty sure the problem is here:&lt;/P&gt;
&lt;P&gt;If find(weighttemp, 'kg', 'i') &amp;lt;there should be a comparison value&amp;gt; then weight = 2.2*input(compress(Weighttemp,,'kd', 8. ));&lt;/P&gt;
&lt;P&gt;such as&lt;/P&gt;
&lt;P&gt;If find(weighttemp, 'kg', 'i') &amp;gt;0&amp;nbsp;then weight = 2.2*input(compress(Weighttemp,,'kd', 8. ));&lt;/P&gt;
&lt;P&gt;and will be needed for both IF statements.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 21:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396498#M95741</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-15T21:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396509#M95745</link>
      <description>&lt;P&gt;Check your parentheses, I think the closing ones are in the wrong places.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 22:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396509#M95745</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-15T22:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396516#M95747</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;hit the nail on the head, I believe. &amp;nbsp;You have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If find(weighttemp, 'kg', 'i') then weight = 2.2*input(compress(Weighttemp,,'kd', 8. &lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if find(weighttemp, 'lbs', 'i') then weight = input(compress(Weighttemp,,'kd', 8. &lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This should work:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If find(weighttemp, 'kg', 'i') then weight = 2.2*input(compress(Weighttemp,,'kd'&lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;, 8. );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if find(weighttemp, 'lbs', 'i') then weight = input(compress(Weighttemp,,'kd'&lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;, 8. ) ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 23:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396516#M95747</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-15T23:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Compress function difficulty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396517#M95748</link>
      <description>&lt;PRE&gt;Hi, I did use the &amp;gt; 0 as recommended, but I am still getting the same error. Below is the code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;libname Learn '/folders/myfolders/Learn' ;

Data Prob12_8 ; 
	Set learn.study(rename = (Weight = WeightTemp)) ; 
	If find(weighttemp, 'kg', 'i') &amp;gt; 0 then weight = 2.2*input(compress(Weighttemp,,'kd', 8.)) ;
	else if find(weighttemp, 'lbs', 'i') &amp;gt; 0 then weight = input(compress(Weighttemp,,'kd', 8.)) ; 

proc print data=Prob12_8 noobs ; 
run ; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;----------------&lt;/PRE&gt;&lt;DIV class="dijitBorderContainer dijitContainer dijitBorderContainer-child dijitBorderContainer-dijitBorderContainer dijitBorderContainerPane dijitAlignCenter dijitLayoutContainer"&gt;&lt;DIV class="dijitContentPane dijitBorderContainer-child dijitBorderContainer-dijitContentPane dijitBorderContainerPane dijitAlignCenter"&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Below is the log:&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;62 /* Chapter 12*/&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;63 /* Problem 12.8*/&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;64 libname Learn '/folders/myfolders/Learn' ;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Libref LEARN was successfully assigned as follows:&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Engine: V9&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Physical Name: /folders/myfolders/Learn&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;65&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;66 Data Prob12_8 ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;67 Set learn.study(rename = (Weight = WeightTemp)) ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;68 If find(weighttemp, 'kg', 'i') &amp;gt; 0 then weight = 2.2*input(compress(Weighttemp,,'kd', 8.)) ;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;69 else if find(weighttemp, 'lbs', 'i') &amp;gt; 0 then weight = input(compress(Weighttemp,,'kd', 8.)) ;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasError focus-line"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;70&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.PROB12_8 may be incomplete. When this step was stopped there were 0 observations and 6 variables.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Data set WORK.PROB12_8 was not replaced because this step was stopped.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;71 proc print data=Prob12_8 noobs ;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72 run ;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: No observations in data set WORK.PROB12_8.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;88&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 Sep 2017 00:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Compress-function-difficulty/m-p/396517#M95748</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-16T00:05:18Z</dc:date>
    </item>
  </channel>
</rss>

