<?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 do i scramble the subject id across the datasets without making any change to actual subject in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783842#M250036</link>
    <description>&lt;P&gt;Hi . Could please provide me a sample code for mapping table and remapping . It would be helpful.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 06:37:30 GMT</pubDate>
    <dc:creator>Prudhvi_007</dc:creator>
    <dc:date>2021-12-03T06:37:30Z</dc:date>
    <item>
      <title>How do i scramble the subject id across the datasets without making any change to actual subject id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783385#M249770</link>
      <description>&lt;P&gt;I have 4 datasets - A,B,C,D. Each dataset has around 500 observations. The subjects need to be scrambled within the available subject ID's. For example Actual subjects are 101,102,103,104 , they need to be scrambled as 103,101,104,102 . I am instructed to merge 4 datasets and apply scrambling for those which have subjects in dataset A. For example if dataset A has 101 as subject id and any of the datasets B,C or D has 101 as Subject id it should be scrambled with same number. Unmatched subjects should remain as it is .&lt;/P&gt;&lt;P&gt;Eg 1. &lt;FONT color="#000000"&gt;A-101 B-101 C-101 D-101&lt;/FONT&gt; -Actual subjects.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A-103&amp;nbsp; B-103 C-103 D-103 - Scrambled subjects should be same across the datasets for a&amp;nbsp; particular subject.&lt;/P&gt;&lt;P&gt;Eg 2. &lt;FONT color="#FF0000"&gt;A-104&lt;/FONT&gt; B-105 C-109&lt;FONT color="#FF0000"&gt; D-104&lt;/FONT&gt; - Actual subjects&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;A-107&lt;/FONT&gt; B-108 C-106 &lt;FONT color="#FF0000"&gt;D-107&lt;/FONT&gt; - Please observe scrambling for Dataset A and D.&lt;/P&gt;&lt;P&gt;Please help me with this requirement .&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 13:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783385#M249770</guid>
      <dc:creator>Prudhvi_007</dc:creator>
      <dc:date>2021-12-01T13:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do i scramble the subject id across the datasets without making any change to actual subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783386#M249771</link>
      <description>&lt;P&gt;Sorry, I don't really understand the requirement.&lt;/P&gt;
&lt;P&gt;I would never tweak identifiers and map to other exisrting ones. Why?&lt;/P&gt;
&lt;P&gt;For the sake of anomonymization I can see a reason to transform id's, but that is usuallly to a new value domain.&lt;/P&gt;
&lt;P&gt;Nevertheless, I guess if you create a mapping table with original id, and the corresponding scrambled id, you can use that to remap data fram any data set.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 14:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783386#M249771</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2021-12-01T14:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do i scramble the subject id across the datasets without making any change to actual subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783396#M249778</link>
      <description>&lt;P&gt;Sort your datasets by ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create a dataset with the IDs from A in random order:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;                                  
  create table newids as select            
    id as new_id from a order by ranuni(0);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And put that together with the original IDs from A:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data scramble;   
  set a(keep=id);
  set newids;    
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then for each of your original datasets, do the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data X;                    
  merge X(in=ok) scramble; 
  by id;                   
  if ok;                   
  id=coalesce(new_id,id);  
  drop new_id;             
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The COALESCE function is not necessary for the A dataset, but it does not hurt much (a very slight performance penalty).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 15:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783396#M249778</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-12-01T15:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do i scramble the subject id across the datasets without making any change to actual subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783842#M250036</link>
      <description>&lt;P&gt;Hi . Could please provide me a sample code for mapping table and remapping . It would be helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 06:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-scramble-the-subject-id-across-the-datasets-without/m-p/783842#M250036</guid>
      <dc:creator>Prudhvi_007</dc:creator>
      <dc:date>2021-12-03T06:37:30Z</dc:date>
    </item>
  </channel>
</rss>

