<?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 Can we get the same ex2 dataset in data step also? If so please give me the code in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99376#M819</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data best; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10; &lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines; &lt;/P&gt;&lt;P&gt;01 A CR 0 &lt;/P&gt;&lt;P&gt;02 A PD 1 &lt;/P&gt;&lt;P&gt;03 B PR 1 &lt;/P&gt;&lt;P&gt;04 B CR 2 &lt;/P&gt;&lt;P&gt;05 C SD 1 &lt;/P&gt;&lt;P&gt;06 C SD 3 &lt;/P&gt;&lt;P&gt;07 C PD 2 &lt;/P&gt;&lt;P&gt;01 A CR 0 &lt;/P&gt;&lt;P&gt;03 B PD 1 &lt;/P&gt;&lt;P&gt;&amp;nbsp; ; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;proc sort data=best nodup out=ex2; &lt;/P&gt;&lt;P&gt;&amp;nbsp; by arm patient; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Jul 2012 11:31:53 GMT</pubDate>
    <dc:creator>devarayalu</dc:creator>
    <dc:date>2012-07-04T11:31:53Z</dc:date>
    <item>
      <title>Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99376#M819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data best; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10; &lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines; &lt;/P&gt;&lt;P&gt;01 A CR 0 &lt;/P&gt;&lt;P&gt;02 A PD 1 &lt;/P&gt;&lt;P&gt;03 B PR 1 &lt;/P&gt;&lt;P&gt;04 B CR 2 &lt;/P&gt;&lt;P&gt;05 C SD 1 &lt;/P&gt;&lt;P&gt;06 C SD 3 &lt;/P&gt;&lt;P&gt;07 C PD 2 &lt;/P&gt;&lt;P&gt;01 A CR 0 &lt;/P&gt;&lt;P&gt;03 B PD 1 &lt;/P&gt;&lt;P&gt;&amp;nbsp; ; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;proc sort data=best nodup out=ex2; &lt;/P&gt;&lt;P&gt;&amp;nbsp; by arm patient; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 11:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99376#M819</guid>
      <dc:creator>devarayalu</dc:creator>
      <dc:date>2012-07-04T11:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99377#M820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not easy with an unsorted dataset.&amp;nbsp; You could store the concatenated values of arm and patient in a temporary array which adds 1 for each row read in, then compare the value of the current row with the previous array values.&amp;nbsp; If it matches then delete the row.&amp;nbsp; This means the maximum array size will be the number of rows in the dataset, I imagine this could cause memory issues for large datasets.&lt;/P&gt;&lt;P&gt;The main question is why you want to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 11:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99377#M820</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-07-04T11:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99378#M821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since "nodup" option (NODUPRECS) is used with proc sort statement there will be 8 records in the final data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines eof=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ = 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h(ordered:'a');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.defineKey('arm','patient','bestres','delay');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.defineDone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if h.check() ne 0 then h.replace();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; last: h.output(dataset:'ex2');&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;01 A CR 0&lt;/P&gt;&lt;P&gt;02 A PD 1&lt;/P&gt;&lt;P&gt;03 B PR 1&lt;/P&gt;&lt;P&gt;04 B CR 2&lt;/P&gt;&lt;P&gt;05 C SD 1&lt;/P&gt;&lt;P&gt;06 C SD 3&lt;/P&gt;&lt;P&gt;07 C PD 2&lt;/P&gt;&lt;P&gt;01 A CR 0&lt;/P&gt;&lt;P&gt;03 B PD 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 11:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99378#M821</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-07-04T11:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99379#M822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the misunderstanding. My question is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any alternate approach to remove duplicates in Data step after doing sorting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 11:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99379#M822</guid>
      <dc:creator>devarayalu</dc:creator>
      <dc:date>2012-07-04T11:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99380#M823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you trying to de-dup by values (arm, patient) or onservations (arm, patient, bestres, delay)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 12:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99380#M823</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-07-04T12:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99381#M824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apologies, I was thinking the 'nodupkey' was in place, not 'nodup'.&amp;nbsp; I have another method of achieving your output dataset, using PROC SUMMARY.&amp;nbsp; This works fine for datasets with not many variables and rows, but I wouldn't recommend using it for large datasets.&amp;nbsp; You won't need to presort the data this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary data=best nway;&lt;/P&gt;&lt;P&gt;class _all_;&lt;/P&gt;&lt;P&gt;output out=ex2 (drop=_:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 12:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99381#M824</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-07-04T12:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99382#M825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your sample data has presented a complex situation, which makes me wonder what your true intention is:&lt;/P&gt;&lt;P&gt;1. you used 'nodup' instead of 'nodupkey', which will NOT work on nonadjacent duplicates BY KEYS, such as 1st and 9th obs.&lt;/P&gt;&lt;P&gt;2. if you just want no duplicates in term of all variables, you can use 'nodup' plus 'by _all_'.&lt;/P&gt;&lt;P&gt;3. if you want your input and output as is, like Keith said, that would be difficult using just data step. However, in case what you really want is 'nodupkey' or no duplicates for all variables, data step hash() has its' native edge:&lt;/P&gt;&lt;P&gt;/*nodupkey equivalent, and no duplicates for all variables only need minor tweak to the following code*/&lt;/P&gt;&lt;P&gt;data best;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;01 A CR 0&lt;/P&gt;&lt;P&gt;02 A PD 1&lt;/P&gt;&lt;P&gt;03 B PR 1&lt;/P&gt;&lt;P&gt;04 B CR 2&lt;/P&gt;&lt;P&gt;05 C SD 1&lt;/P&gt;&lt;P&gt;06 C SD 3&lt;/P&gt;&lt;P&gt;07 C PD 2&lt;/P&gt;&lt;P&gt;01 A CR 0&lt;/P&gt;&lt;P&gt;03 B PD 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set best;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash h(dataset:'best', ordered:'a');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definekey('arm','patient');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definedata(all:'y');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; _rc=h.output(dataset:'ex2');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 12:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99382#M825</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-04T12:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get the same ex2 dataset in data step also? If so please give me the code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99383#M826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seems you are looking a way to remove duplicates on some key variables (method other than proc sort nodupkey):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See if it helps:&lt;/P&gt;&lt;P&gt;data best; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input patient 1-2 arm $ 4-5 bestres $ 6-7 delay 9-10; &lt;BR /&gt;datalines; &lt;BR /&gt;01 A CR 0 &lt;BR /&gt;02 A PD 1 &lt;BR /&gt;03 B PR 1 &lt;BR /&gt;04 B CR 2 &lt;BR /&gt;05 C SD 1 &lt;BR /&gt;06 C SD 3 &lt;BR /&gt;07 C PD 2 &lt;BR /&gt;01 A CR 0 &lt;BR /&gt;03 B PD 1 &lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=best ; &lt;BR /&gt;by arm patient; &lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data uniq;&lt;BR /&gt;set best;&lt;BR /&gt;by arm patient;&lt;BR /&gt;if first.patient;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jun 2013 14:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Can-we-get-the-same-ex2-dataset-in-data-step-also-If-so-please/m-p/99383#M826</guid>
      <dc:creator>pali</dc:creator>
      <dc:date>2013-06-25T14:34:24Z</dc:date>
    </item>
  </channel>
</rss>

