<?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 Replace values in a numeric table based on a character table in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919119#M41163</link>
    <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following two datasets:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set1;&lt;BR /&gt;input Variable1 Variable2;&lt;BR /&gt;cards;&lt;BR /&gt;124.3 342.0&lt;BR /&gt;721.30 876.05&lt;BR /&gt;. 654.98&lt;BR /&gt;. 543.6&lt;BR /&gt;456.1 .&lt;BR /&gt;39 .&lt;BR /&gt;783.01 .&lt;BR /&gt;765.10 765.0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set2;&lt;BR /&gt;input Variable1 $ Variable2 $;&lt;BR /&gt;cards;&lt;BR /&gt;1243 3420&lt;BR /&gt;72130 87605&lt;BR /&gt;V2540 65498&lt;BR /&gt;. 543.6&lt;BR /&gt;4561 V3461&lt;BR /&gt;39 .&lt;BR /&gt;78301 .&lt;BR /&gt;76510 7650&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me with these two issues?&lt;/P&gt;
&lt;P&gt;1) prevent to trim the 0s at the end of numbers in set1 (not to round at the integer when there is 0 as the only one decimal because in my data&amp;nbsp;342.0 (chosen as an example) is an information while&amp;nbsp;342 is another one. They are not equivalent and so .0 must be there) ;&lt;/P&gt;
&lt;P&gt;2) I need to replace missing values in set1 with values in set2 when they are available in set2. If a value is missing in set2 and missing in set1 no action must be done. The remaining values must be as in set1, i.e., for example&amp;nbsp;124.3 must remain as is and not transformed as&amp;nbsp;1243.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My issue is that while set1 is numeric, set2 is character. Maybe set1 could be transformed as character but I need that numbers must remain as they are, i.e.,&amp;nbsp;124.3 and not&amp;nbsp;1243.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output (in bold replaced values):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="190"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;Variable1&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;Variable2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;124.3&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;342.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;721.30&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;876.05&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;&lt;STRONG&gt;V2540&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;654.98&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;543.6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;456.1&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&lt;STRONG&gt;V3461&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;39&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;783.01&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;765.10&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;765.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Wed, 06 Mar 2024 15:00:25 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2024-03-06T15:00:25Z</dc:date>
    <item>
      <title>Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919119#M41163</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following two datasets:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set1;&lt;BR /&gt;input Variable1 Variable2;&lt;BR /&gt;cards;&lt;BR /&gt;124.3 342.0&lt;BR /&gt;721.30 876.05&lt;BR /&gt;. 654.98&lt;BR /&gt;. 543.6&lt;BR /&gt;456.1 .&lt;BR /&gt;39 .&lt;BR /&gt;783.01 .&lt;BR /&gt;765.10 765.0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set2;&lt;BR /&gt;input Variable1 $ Variable2 $;&lt;BR /&gt;cards;&lt;BR /&gt;1243 3420&lt;BR /&gt;72130 87605&lt;BR /&gt;V2540 65498&lt;BR /&gt;. 543.6&lt;BR /&gt;4561 V3461&lt;BR /&gt;39 .&lt;BR /&gt;78301 .&lt;BR /&gt;76510 7650&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me with these two issues?&lt;/P&gt;
&lt;P&gt;1) prevent to trim the 0s at the end of numbers in set1 (not to round at the integer when there is 0 as the only one decimal because in my data&amp;nbsp;342.0 (chosen as an example) is an information while&amp;nbsp;342 is another one. They are not equivalent and so .0 must be there) ;&lt;/P&gt;
&lt;P&gt;2) I need to replace missing values in set1 with values in set2 when they are available in set2. If a value is missing in set2 and missing in set1 no action must be done. The remaining values must be as in set1, i.e., for example&amp;nbsp;124.3 must remain as is and not transformed as&amp;nbsp;1243.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My issue is that while set1 is numeric, set2 is character. Maybe set1 could be transformed as character but I need that numbers must remain as they are, i.e.,&amp;nbsp;124.3 and not&amp;nbsp;1243.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output (in bold replaced values):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="190"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;Variable1&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;Variable2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;124.3&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;342.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;721.30&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;876.05&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;&lt;STRONG&gt;V2540&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;654.98&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;543.6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;456.1&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&lt;STRONG&gt;V3461&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;39&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;783.01&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="94.625px" height="30px"&gt;765.10&lt;/TD&gt;
&lt;TD width="94.7083px" height="30px"&gt;765.0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919119#M41163</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-03-06T15:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919123#M41164</link>
      <description>&lt;P&gt;is there any ID variable linking these datasets? &amp;nbsp;and do you want the variables to be char or numeric?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919123#M41164</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2024-03-06T15:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919124#M41165</link>
      <description>Unfortunately there is not an ID variable. I received data as they appear here. I think I can add easily by numbering from 1 to the n rows of the table. I think they can be as character.</description>
      <pubDate>Wed, 06 Mar 2024 15:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919124#M41165</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-03-06T15:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919126#M41166</link>
      <description>&lt;P&gt;do you want decimals or not? because your desired output you added some decimals to var2 from set2 that weren't there before.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919126#M41166</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2024-03-06T15:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919133#M41167</link>
      <description>&lt;P&gt;try this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data set1;
input Variable1 Variable2;
cards;
124.3 342.0
721.30 876.05
. 654.98
. 543.6
456.1 .
39 .
783.01 .
765.10 765.0
;
run;

data set1_1;
   set set1;
   id=_n_;
   if variable1 ne . then var1=strip(put(variable1,8.2));
   if variable2 ne . then var2=strip(put(variable2,8.2));
run;
 
data set2;
input Variable1 $ Variable2 $;
id=_n_;
cards;
1243 3420
72130 87605
V2540 65498
. 543.6
4561 V3461
39 .
78301 .
76510 7650
;
run;

proc sql;
   create table set3 as 
   select s1.var1, s1.var2, s2.variable1, s2.variable2
      from set1_1 as s1
      left join set2 as s2
      on s1.id=s2.id;
quit;

data want;
   set set3;
   if missing(var1) and ^missing(variable1) then var1=variable1;
   if missing(var2) and ^missing(variable2) then var2=variable2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919133#M41167</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2024-03-06T15:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919143#M41168</link>
      <description>Thank you very much  tarheel13 but regarding the use of strip it doesn't work because looking for example at the first number 124.3 it becomes 124.30 that has a different meaning compared with 124.3 that must remain as it is.</description>
      <pubDate>Wed, 06 Mar 2024 16:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919143#M41168</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-03-06T16:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919144#M41169</link>
      <description>&lt;P&gt;To prevent the trailing zeros after the decimal place from being removed do NOT convert the strings in numbers.&amp;nbsp; There is no difference between 342 and 342.0 as they both represent the same number as 300+40+2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are these ICD9 codes?&amp;nbsp; If so store them as character only.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 16:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919144#M41169</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-06T16:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919145#M41170</link>
      <description>Wow, you won! Unfortunately yes they are ICD9 (devil). If I store them as character the code you provided me in my previous post doesn't work. It rounds numbers.</description>
      <pubDate>Wed, 06 Mar 2024 16:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919145#M41170</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-03-06T16:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919146#M41171</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Wow, you won! Unfortunately yes they are ICD9 (devil). If I store them as character the code you provided me in my previous post doesn't work. It rounds numbers.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Store the ICD codes without the period.&amp;nbsp; It saves a space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always put it back in if you want it to look pretty in a report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 16:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919146#M41171</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-06T16:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in a numeric table based on a character table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919147#M41172</link>
      <description>Ok sounds the best solution also for further computations. I will keep them as they are until the analysis will be finished. Thank you very much!</description>
      <pubDate>Wed, 06 Mar 2024 16:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replace-values-in-a-numeric-table-based-on-a-character-table/m-p/919147#M41172</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-03-06T16:23:33Z</dc:date>
    </item>
  </channel>
</rss>

