<?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 Creating code to apply a list of changes to a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471450#M120762</link>
    <description>&lt;P&gt;I am managing a data set from surveys that are administered through a program. Sometimes, an error occurs when entering an answer or variable during the survey and something needs to be changed after the survey data has already been stored. These changes are stored in a database given the following information:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Process Order (p_order)&lt;/STRONG&gt;: Order in which the error should be processed (This variable is created in case there are multiple errors on one survey)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Survey ID (surid):&lt;/STRONG&gt; ID of the survey participant&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interviewer ID (icode):&lt;/STRONG&gt; ID of the interviewer&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interview Start time (start):&lt;/STRONG&gt; Start time of the interview&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interview Date (idate):&lt;/STRONG&gt; Date of the interview&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Variable Name (name):&lt;/STRONG&gt; Name of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Old Value (o_value):&lt;/STRONG&gt; Old value of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;New Value (n_value):&lt;/STRONG&gt; New value of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a SAS code that I can run which will search through the survey SAS data set and find the matching observation with the same surid, icode, start, and idate and also has the same o_value for the desired variable we want to change. Then the code should change the value from old to new.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i could do it by hand, but I am hoping to find a way to efficiently code this up to automate it. I think it would make sense to pull one observation at a time from the data error log and apply it to the survey data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping for any advice you can provide!!&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jun 2018 17:23:26 GMT</pubDate>
    <dc:creator>sasuser31</dc:creator>
    <dc:date>2018-06-19T17:23:26Z</dc:date>
    <item>
      <title>Creating code to apply a list of changes to a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471450#M120762</link>
      <description>&lt;P&gt;I am managing a data set from surveys that are administered through a program. Sometimes, an error occurs when entering an answer or variable during the survey and something needs to be changed after the survey data has already been stored. These changes are stored in a database given the following information:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Process Order (p_order)&lt;/STRONG&gt;: Order in which the error should be processed (This variable is created in case there are multiple errors on one survey)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Survey ID (surid):&lt;/STRONG&gt; ID of the survey participant&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interviewer ID (icode):&lt;/STRONG&gt; ID of the interviewer&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interview Start time (start):&lt;/STRONG&gt; Start time of the interview&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interview Date (idate):&lt;/STRONG&gt; Date of the interview&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Variable Name (name):&lt;/STRONG&gt; Name of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Old Value (o_value):&lt;/STRONG&gt; Old value of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;New Value (n_value):&lt;/STRONG&gt; New value of the variable that needs to be changed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a SAS code that I can run which will search through the survey SAS data set and find the matching observation with the same surid, icode, start, and idate and also has the same o_value for the desired variable we want to change. Then the code should change the value from old to new.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i could do it by hand, but I am hoping to find a way to efficiently code this up to automate it. I think it would make sense to pull one observation at a time from the data error log and apply it to the survey data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping for any advice you can provide!!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 17:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471450#M120762</guid>
      <dc:creator>sasuser31</dc:creator>
      <dc:date>2018-06-19T17:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating code to apply a list of changes to a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471466#M120765</link>
      <description>&lt;P&gt;What happens if you don't find the old value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you made changes irrespective of the old value, this operation could be done simply&amp;nbsp;with an UPDATE statement in a datastep.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 18:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471466#M120765</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-19T18:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating code to apply a list of changes to a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471474#M120768</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100524"&gt;@sasuser31&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am managing a data set from surveys that are administered through a program. Sometimes, an error occurs when entering an answer or variable during the survey and something needs to be changed after the survey data has already been stored. These changes are stored in a database given the following information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Process Order (p_order)&lt;/STRONG&gt;: Order in which the error should be processed (This variable is created in case there are multiple errors on one survey)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Survey ID (surid):&lt;/STRONG&gt; ID of the survey participant&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Interviewer ID (icode):&lt;/STRONG&gt; ID of the interviewer&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Interview Start time (start):&lt;/STRONG&gt; Start time of the interview&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Interview Date (idate):&lt;/STRONG&gt; Date of the interview&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Variable Name (name):&lt;/STRONG&gt; Name of the variable that needs to be changed&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Old Value (o_value):&lt;/STRONG&gt; Old value of the variable that needs to be changed&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;New Value (n_value):&lt;/STRONG&gt; New value of the variable that needs to be changed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a SAS code that I can run which will search through the survey SAS data set and find the matching observation with the same surid, icode, start, and idate and also has the same o_value for the desired variable we want to change. Then the code should change the value from old to new.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know i could do it by hand, but I am hoping to find a way to efficiently code this up to automate it. I think it would make sense to pull one observation at a time from the data error log and apply it to the survey data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hoping for any advice you can provide!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide some example data of your correction set and base data&amp;nbsp;in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are actually missing a piece of information that will be critical for any automated process to work: Is the value of "Old Value" and/or "New Value" numeric or character? So there will likely have to be a step to pull that information from the data to be corrected so the values of o_value and n_value can be presented correctly. Also Formats may come into play.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am &lt;STRONG&gt;assuming&lt;/STRONG&gt; that the data types of your other variables exactly match the values in you data to correct.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 18:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471474#M120768</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-19T18:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating code to apply a list of changes to a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471524#M120792</link>
      <description>&lt;P&gt;So here is a small made up example (cannot provide real data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Survey Data&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;surid&lt;/TD&gt;&lt;TD&gt;icode&lt;/TD&gt;&lt;TD&gt;Idate&lt;/TD&gt;&lt;TD&gt;start&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;eligibility&lt;/TD&gt;&lt;TD&gt;Venue&lt;/TD&gt;&lt;TD&gt;Age&lt;/TD&gt;&lt;TD&gt;Sex&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;12/20/2018&lt;/TD&gt;&lt;TD&gt;9:38:24&lt;/TD&gt;&lt;TD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;&lt;TD&gt;Sex&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&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;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 21:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/471524#M120792</guid>
      <dc:creator>sasuser31</dc:creator>
      <dc:date>2018-06-19T21:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating code to apply a list of changes to a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/472301#M121089</link>
      <description>&lt;P&gt;How would I use an update statement? I cant seem to put the pieces together since there are several different variables that&amp;nbsp; could need to&amp;nbsp; be updated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 21:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-code-to-apply-a-list-of-changes-to-a-dataset/m-p/472301#M121089</guid>
      <dc:creator>sasuser31</dc:creator>
      <dc:date>2018-06-21T21:49:37Z</dc:date>
    </item>
  </channel>
</rss>

