<?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: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491430#M72164</link>
    <description>&lt;P&gt;Hi Suryakiran,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That worked like a charm...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your time hope this helps other people in the future...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set abc_Merged_001AAa;&lt;BR /&gt;by AMI;&lt;BR /&gt;if not first.AMI then EMP_CTB_AMT=0;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Aug 2018 21:04:37 GMT</pubDate>
    <dc:creator>SRemm</dc:creator>
    <dc:date>2018-08-30T21:04:37Z</dc:date>
    <item>
      <title>How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491392#M72159</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have three large data sets that I merge into one data set data set - one has 20121 rows and data set 2 and 3 have 20143 rows I sort them all on the Emp identifier then run the merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After I merge the three I end up with 20143 rows but I end up with 22 members with a duplicate Contribution amount gets added twice with the merge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To resolve it I take my finished report exported into Excel and find duplicate SSN and high light them&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I filter the 20143 rows on the color high light to bring them to the top of the list&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I manually update the Emp Contribtion amounts to zero for one of the duplicate values - this is where NODUPRECS NODUPKEY dropped the entire dup rows and the other variables amounts in the rows are needed or it tosses off my other column amounts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a modify or update data step or SQL or case that I can clean up those rows with a dup member identifier that also have a dup contribution amount to update one of them to zero.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SR-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;data abc_Merged_001AAa;&lt;BR /&gt;&lt;BR /&gt;MERGE abc_STEP2_SORTEDA abc_STEP3_SORTED_A abc_STEP1_SORTEDa ;&lt;BR /&gt;by ami&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;;&lt;BR /&gt;&amp;nbsp;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: MERGE statement has more than one data set with repeats of BY values.&lt;BR /&gt;NOTE: There were 20143 observations read from the data set WORK.abc_STEP2_SORTEDA.&lt;BR /&gt;NOTE: There were 20121 observations read from the data set WORK.abc_STEP3_SORTED_D.&lt;BR /&gt;NOTE: There were 20143 observations read from the data set WORK.abc_STEP1_SORTEDA.&lt;BR /&gt;NOTE: The data set WORK.abc_MERGED_001AAA has 20143 observations and 21 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 19:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491392#M72159</guid>
      <dc:creator>SRemm</dc:creator>
      <dc:date>2018-08-30T19:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491397#M72160</link>
      <description>&lt;P&gt;&lt;STRONG&gt;FIRST.&lt;/STRONG&gt; would solve your problem.&lt;/P&gt;
&lt;P&gt;Something like: If not first.id then col=0;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 19:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491397#M72160</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-30T19:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491398#M72161</link>
      <description>&lt;P&gt;Thanks Suryakiran&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So col=0 as in col is the variable name??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SR-&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 20:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491398#M72161</guid>
      <dc:creator>SRemm</dc:creator>
      <dc:date>2018-08-30T20:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491404#M72162</link>
      <description>&lt;P&gt;Sort the data by the Key variable you have (In your case I guess it's ami ) and then change the variable values as required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id val;
datalines;
1 20
1 30
1 50
2 10
3 20
4 40
;
run;
proc sort data=have;
by id val;
run;
data want;
set have;
by id;
if not first.id then val=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Aug 2018 20:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491404#M72162</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-30T20:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491414#M72163</link>
      <description>&lt;P&gt;We could probably help with this significantly easier if you could provide a small data sample that reflects the issue and what you want as final output. It does not have to be your real data, but should be reflective of your data, such as if you're doing it by specific groups make sure to include more than one group of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;After I merge the three I end up with 20143 rows but I end up with 22 members with a duplicate Contribution amount gets added twice with the merge.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Usually to me that means you need to add some other condition to the merge, or de-duplicate a data set before the merge.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I am looking for a modify or update data step or SQL or case that I can clean up those rows with a dup member identifier that also have a dup contribution amount to update one of them to zero.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;BY group processing will identify multiple groups if you have a key set of variables that identify a 'group'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then if its not the first of the group you can set those values to 0 or missing. You may want missing so they're not included as N's for summary statistics, whereas missing&amp;nbsp;would be excluded automatically, 0's could throw off averages or other calculations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
by make model mpg_highway;
run;

data identify_first;
set cars;
by Make; *note only make this time;

if NOT first.make then mpg_highway=0;*set to 0;
if NOT first.make then mpg_highway=.; *set to missing;


keep make model mpg_highway; *limit data for example;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4804"&gt;@SRemm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have three large data sets that I merge into one data set data set - one has 20121 rows and data set 2 and 3 have 20143 rows I sort them all on the Emp identifier then run the merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After I merge the three I end up with 20143 rows but I end up with 22 members with a duplicate Contribution amount gets added twice with the merge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To resolve it I take my finished report exported into Excel and find duplicate SSN and high light them&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I filter the 20143 rows on the color high light to bring them to the top of the list&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I manually update the Emp Contribtion amounts to zero for one of the duplicate values - this is where NODUPRECS NODUPKEY dropped the entire dup rows and the other variables amounts in the rows are needed or it tosses off my other column amounts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a modify or update data step or SQL or case that I can clean up those rows with a dup member identifier that also have a dup contribution amount to update one of them to zero.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SR-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;data abc_Merged_001AAa;&lt;BR /&gt;&lt;BR /&gt;MERGE abc_STEP2_SORTEDA abc_STEP3_SORTED_A abc_STEP1_SORTEDa ;&lt;BR /&gt;by ami&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;;&lt;BR /&gt;&amp;nbsp;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: MERGE statement has more than one data set with repeats of BY values.&lt;BR /&gt;NOTE: There were 20143 observations read from the data set WORK.abc_STEP2_SORTEDA.&lt;BR /&gt;NOTE: There were 20121 observations read from the data set WORK.abc_STEP3_SORTED_D.&lt;BR /&gt;NOTE: There were 20143 observations read from the data set WORK.abc_STEP1_SORTEDA.&lt;BR /&gt;NOTE: The data set WORK.abc_MERGED_001AAA has 20143 observations and 21 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 20:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491414#M72163</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-30T20:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a variable value to Zero not drop the entire row like NODUPKEY NODUPRECS options</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491430#M72164</link>
      <description>&lt;P&gt;Hi Suryakiran,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That worked like a charm...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your time hope this helps other people in the future...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set abc_Merged_001AAa;&lt;BR /&gt;by AMI;&lt;BR /&gt;if not first.AMI then EMP_CTB_AMT=0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 21:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-a-variable-value-to-Zero-not-drop-the-entire-row/m-p/491430#M72164</guid>
      <dc:creator>SRemm</dc:creator>
      <dc:date>2018-08-30T21:04:37Z</dc:date>
    </item>
  </channel>
</rss>

