<?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: Modifying a variable in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823559#M325188</link>
    <description>&lt;P&gt;You can do this with SQL or a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  update lib.data1 set a=(select a2 from lib.data2 where id=data1.id) 
  where id in(select id from lib.data2 where salesdate&amp;gt;'01JAN2020'd)
 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or the same thing in a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lib.data1;
  set lib.data2;
  where salesdate&amp;gt;'01JAN2020'd;&lt;BR /&gt;  do until(0);
    modify lib.data1 key=id;&lt;BR /&gt;    if _iorc_ then leave;&lt;BR /&gt;    a=a2;&lt;BR /&gt;    replace;&lt;BR /&gt;    end;
  _error_=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The data step example as shown needs LIB.DATA1 to be indexed by ID.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jul 2022 17:12:50 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2022-07-15T17:12:50Z</dc:date>
    <item>
      <title>Modifying a variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823549#M325178</link>
      <description>&lt;P&gt;Can anyone tell me if have any proc , function or any option available with the help of that&amp;nbsp; we can modify a variable without reading the whole dataset in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It means we don't have&amp;nbsp; to read the whole data set just to modify few variables for e.g&amp;nbsp; Suppose we have 1 billion of record and for one small change we don't want to read whole records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 16:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823549#M325178</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-07-15T16:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823554#M325183</link>
      <description>&lt;P&gt;What do you mean when you say modify? Look at &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p16vqq5oedlmkin1373cqyalhpo6.htm" target="_self"&gt;PROC DATASETS&lt;/A&gt;. Might have your answer depending on what you mean by modify.&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 16:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823554#M325183</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-07-15T16:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823556#M325185</link>
      <description>&lt;P&gt;What specific modifications do you have in mind?&lt;/P&gt;
&lt;P&gt;Changing variable names, labels and formats can be done with Proc Datasets.&lt;/P&gt;
&lt;P&gt;Replacing values can get into some details such as :&lt;/P&gt;
&lt;P&gt;Does every value of XXX get changed to YYY or are the changes conditional?&lt;/P&gt;
&lt;P&gt;If the changes are conditional then you need to describe the condition.&lt;/P&gt;
&lt;P&gt;Is the variable character or numeric? If character what is the current defined length and the required length of the new value (can't stick 10 characters into a length 5 variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Answers to the above point to different possible solutions from UPDATE or MODIFY in data step or completely rebuilding possible rereading the data with custom informat or multiple IF/then/else or similar conditional logic.&lt;/P&gt;
&lt;P&gt;If the answer is an EVERY value type change then perhaps no change is need to the data at all and may be handled by a custom format.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 16:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823556#M325185</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-15T16:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying a variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823559#M325188</link>
      <description>&lt;P&gt;You can do this with SQL or a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  update lib.data1 set a=(select a2 from lib.data2 where id=data1.id) 
  where id in(select id from lib.data2 where salesdate&amp;gt;'01JAN2020'd)
 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or the same thing in a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lib.data1;
  set lib.data2;
  where salesdate&amp;gt;'01JAN2020'd;&lt;BR /&gt;  do until(0);
    modify lib.data1 key=id;&lt;BR /&gt;    if _iorc_ then leave;&lt;BR /&gt;    a=a2;&lt;BR /&gt;    replace;&lt;BR /&gt;    end;
  _error_=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The data step example as shown needs LIB.DATA1 to be indexed by ID.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 17:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-a-variable-in-SAS/m-p/823559#M325188</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-07-15T17:12:50Z</dc:date>
    </item>
  </channel>
</rss>

