<?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: Create new variable based on values/rules in other columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599606#M173109</link>
    <description>yes</description>
    <pubDate>Sun, 27 Oct 2019 03:34:22 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-10-27T03:34:22Z</dc:date>
    <item>
      <title>Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510059#M137217</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Friday! I need to write a piece of code to do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If weight_unit = ‘kg’ and weight is between Low and high in the table below, then dose_volume = value in column 3 &amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Low&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;High&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;≥45&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤49&lt;/P&gt;
&lt;/TD&gt;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&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;gt;79&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤84&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;gt;84&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤89&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;gt;89&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤94&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;12&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;gt;94&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤99&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;13&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;gt;99&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤120&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;13.5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;If weight_unit = ‘lbs’ and weight is between Low and high below, then dose_volume = value in column 3 &amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&g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;
&lt;TD&gt;
&lt;P&gt;&amp;gt;218&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;≤264&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;13.5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Any good code suggestion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THANKS!!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 20:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510059#M137217</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-11-02T20:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Programming codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510060#M137218</link>
      <description>What have you tried so far? What are the formats and types on the data, specifically the low/high variables? Can you please provide data as a data step as illustrated here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And ideally, better subjects please. I'll update this one, but please do try to do this in the future. &lt;BR /&gt;</description>
      <pubDate>Fri, 02 Nov 2018 20:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510060#M137218</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-02T20:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Programming codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510061#M137219</link>
      <description>&lt;P&gt;I can sort out the data type extra, I just need the&amp;nbsp;algorithm if this helps...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 20:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510061#M137219</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-11-02T20:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Programming codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510064#M137220</link>
      <description>Use SCAN or COMPRESS to remove the greater than and less than signs. Create formats using CTNLIN driven from the data sets and then you can use the format in any data step.</description>
      <pubDate>Fri, 02 Nov 2018 20:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510064#M137220</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-02T20:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Programming codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510067#M137222</link>
      <description>&lt;P&gt;could you show me an example, please, I have never use&amp;nbsp;&lt;SPAN&gt;SCAN function and never create formats using CTNLIN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you as always&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 21:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510067#M137222</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-11-02T21:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Programming codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510071#M137225</link>
      <description>If you need code could you please answer some of my original questions, specifically, sample data as a data step. Otherwise, I recommend reading a paper called 'Proc formats, not just another pretty face' for help.</description>
      <pubDate>Fri, 02 Nov 2018 21:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510071#M137225</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-02T21:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510075#M137229</link>
      <description>&lt;P&gt;Is that one data set or two? Also where is the actual data with something that has the UNITS values you depend on using for calculation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I would either use that information to create informats or right SELECT/WHEN/END blocks of code than attempt to deal with parsing out the ≥ and ≤ from data.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 21:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510075#M137229</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-02T21:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510101#M137247</link>
      <description>&lt;P&gt;I have a list of patient Id, weight (numeric), with weight_unit captured in either 'kg' or 'lbs',&lt;/P&gt;&lt;P&gt;so first I need to check the weight_unit through each observation in the list to decide which category I should compare to and then based on their weight assign&amp;nbsp;the&amp;nbsp;&lt;SPAN&gt;dose_volume for each patient. The weight categories in the table (&amp;nbsp;"≥ and ≤") is not in the dataset, they are form the Protocol. Sorry for the confusion&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;If you could show me a short exmaple, that would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 23:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510101#M137247</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-11-02T23:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510108#M137250</link>
      <description>&lt;P&gt;If you want tested code then you need to provide sample data.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are after some sort of grouping. Using SAS Formats or Informats is a great way to do so (creating groups based on the tables you've posted). Look up Proc Format if you don't know how this is done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below some pseudo code how this could work with SAS Informats:&lt;/P&gt;
&lt;PRE&gt;if weight_unit='lbl' then dose_volume=input(weight, lbl_doses.);
else  if weight_unit='kg' then dose_volume=input(weight, kg_doses.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Alternatively first convert everything to kg and then use a single informat.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;if weight_unit='lbl' then weight_in_kg=weight*&amp;lt;conversion factor&amp;gt;;
else weight_in_kg=weight;
dose_volume=input(weight, kg_doses.);&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Nov 2018 03:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510108#M137250</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-11-03T03:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510155#M137274</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;Thank you very much for pointing out the direction&lt;/P&gt;&lt;P&gt;After Proc format into groups and it worked out as I expected, Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 13:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/510155#M137274</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-11-03T13:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599593#M173102</link>
      <description>&lt;P&gt;I am trying to change all of my data into cms when the data has some in inches and some in cms.&amp;nbsp; I have these variables&lt;/P&gt;&lt;P&gt;comor_9hgt&amp;nbsp; variable has actual measurements&lt;/P&gt;&lt;P&gt;comor_9hgtunit_decode = cm =1&amp;nbsp; or inches=2&lt;/P&gt;&lt;P&gt;comor_9hgtunit&amp;nbsp; &amp;nbsp;says cm or inches&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data demo2;&lt;BR /&gt;set mergeddemo;&lt;BR /&gt;If comor_9hgtunit_decode then do;&lt;BR /&gt;height_cm = comor_9hgt/2.54;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;height_cm =comor_9hgt;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 00:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599593#M173102</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-27T00:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599594#M173103</link>
      <description>&lt;P&gt;I am trying to change all of my data into cms when the data has some in inches and some in cms.&amp;nbsp; I have these variables&lt;/P&gt;&lt;P&gt;comor_9hgt&amp;nbsp; variable has actual measurements&lt;/P&gt;&lt;P&gt;comor_9hgtunit_decode = cm =1&amp;nbsp; or inches=2&lt;/P&gt;&lt;P&gt;comor_9hgtunit&amp;nbsp; &amp;nbsp;says cm or inches&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data demo2;&lt;BR /&gt;set mergeddemo;&lt;BR /&gt;If comor_9hgtunit_decode then do;&lt;BR /&gt;height_cm = comor_9hgt/2.54;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;height_cm =comor_9hgt;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting this error message.&amp;nbsp;&amp;nbsp;The data set WORK.DEMO2 may be incomplete. When this&lt;BR /&gt;step was stopped there were 0 observations and 3&lt;BR /&gt;variables.&lt;BR /&gt;WARNING: Data set WORK.DEMO2 was not replaced because this step&lt;BR /&gt;was stopped.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 00:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599594#M173103</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-27T00:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599600#M173104</link>
      <description>Show the full log. Where the error occurs tells you. &lt;BR /&gt;&lt;BR /&gt;I will say that your IF condition is incorrect. &lt;BR /&gt;SAS evaluates any value &amp;gt; 0 as true, so 1/2 would be true and converted, you want to test if the variable is equal to 1 or 2.</description>
      <pubDate>Sun, 27 Oct 2019 03:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599600#M173104</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-27T03:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599602#M173105</link>
      <description>Please do not post the same question in multiple posts.</description>
      <pubDate>Sun, 27 Oct 2019 03:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599602#M173105</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-27T03:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599605#M173108</link>
      <description>&lt;P&gt;The second question was by accident sorry.&amp;nbsp; Do you want to see the full log?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 03:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599605#M173108</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-27T03:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599606#M173109</link>
      <description>yes</description>
      <pubDate>Sun, 27 Oct 2019 03:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599606#M173109</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-27T03:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599607#M173110</link>
      <description>&lt;P&gt;Please find the log attached&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 03:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599607#M173110</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-27T03:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable based on values/rules in other columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599662#M173137</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;284  */ changing inches to cms*/;
285  data demo2;
286  set mergedemo;
&lt;FONT size="4" color="#FF6600"&gt;&lt;STRONG&gt;287 If &lt;/STRONG&gt;&lt;FONT size="6"&gt;c&lt;/FONT&gt;&lt;STRONG&gt;omor_9hgtunit_decode then do;&lt;/STRONG&gt;&lt;/FONT&gt;
288  height_cm = comor_9hgt/2.54;
289  end;
290  else do;
291  height_cm =comor_9hgt;
292  end;
293  run;
&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;NOTE: Character values have been converted to numericvalues at the places given by: (Line):(Column).287:4&lt;/STRONG&gt;&lt;/FONT&gt;
NOTE: Invalid numeric data, &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;comor_9hgtunit_decode='cm'&lt;/STRONG&gt;&lt;/FONT&gt; , atline 287 column 4.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See how the log indicates where the error is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It says Line 287:4, which happens to be this&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;comor_9hgtunit_decode&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Your code is incorrect, it should be checking&amp;nbsp;against a value as I indicated earlier. I&amp;nbsp;believe you're trying to convert&amp;nbsp;inches to cm so check if the value is inches.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If &lt;FONT size="5" color="#FF6600"&gt;&lt;STRONG&gt;comor_9hgtunit_decode = 'inches'&lt;/STRONG&gt;&lt;/FONT&gt; then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Please find the log attached&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Also, when you paste the log into a document not everyone can view it - I can't if I'm at work for example. Additionally, when I copied and pasted it back here I had to reformat it. So in the future please, paste only the code and log that has the errors starting from the first error and paste the log directly into the forum, similar to how I did for my response. Use the 6th icon in the editor to insert the log. This makes it much easier and faster to answer your question and our computer don't get clogged with downloads.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 17:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-based-on-values-rules-in-other-columns/m-p/599662#M173137</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-27T17:33:49Z</dc:date>
    </item>
  </channel>
</rss>

