<?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: storing a computed  variable into data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495176#M130638</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43025"&gt;@error_prone&lt;/a&gt; thanks for your reply I was hoping there would be some way out.&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 06:40:33 GMT</pubDate>
    <dc:creator>ariyurjana</dc:creator>
    <dc:date>2018-09-13T06:40:33Z</dc:date>
    <item>
      <title>storing a computed  variable into data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495139#M130624</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am computing a variable in a data set and want to output only this variable into the data set.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
set b c;
xvar = &amp;lt;some calculation using fields from datasets b and c &amp;gt; ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to append/add only this xvar into dataset a and ignore other variables in the PDV. I have many variable and keep and drop is getting tedious.&lt;/P&gt;&lt;P&gt;My question is how can I selectively select variables from the PDV and write to the data set a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. My second question is regarding aliasing. Is there sql like aliasing within the dataset code. I dont want to use proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
set b alias x c alias y;

if x.fld1 &amp;lt;&amp;gt; y.fld1 then do;
&amp;lt;some processing&amp;gt;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 03:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495139#M130624</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-09-13T03:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: storing a computed  variable into data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495167#M130634</link>
      <description>Use the keep-statement to control which variables are written to the output-datasets.&lt;BR /&gt;If you use more the one dataset in SET the datasets are append, maybe you need a merge to get what you want. And, no, the concept of aliasing does not exist in the data-step.</description>
      <pubDate>Thu, 13 Sep 2018 05:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495167#M130634</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-09-13T05:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: storing a computed  variable into data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495176#M130638</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43025"&gt;@error_prone&lt;/a&gt; thanks for your reply I was hoping there would be some way out.&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jana&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 06:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495176#M130638</guid>
      <dc:creator>ariyurjana</dc:creator>
      <dc:date>2018-09-13T06:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: storing a computed  variable into data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495196#M130650</link>
      <description>&lt;P&gt;What do you mean - "I was hoping there would be some way out"?&amp;nbsp; If there is no logical way of identifying variables - such as using prefix's and then shortcuts that way, then how can the computer know what you want to keep?&amp;nbsp; We need to see concrete examples - with test data in the form of a datastep showing what you see.&amp;nbsp; If for instance you want to keep all variables with varX (X being a number), then its simple to do var:, or you can do by position var1--var10.&amp;nbsp; However if you have that many variables all named differently then I would have to suggest you have modeled the data badly, probably thinking in Excel terms, which is common and leads to tranposed datasets which are harder to work with in numerous ways - such as you are finding with specifying each column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In terms of your second question, you can do:&lt;/P&gt;
&lt;PRE&gt;data a;
  set b (in=b) x (in=x) c (in=y);
  if x then do;
...
run;&lt;/PRE&gt;
&lt;P&gt;Its very hard to tell from the zero information provided.&amp;nbsp; But whilst you can use aliases with set, that just sets one dataset under the other, so makes no sense as x.fld is never going to be equal to y.fld, as neither comes from the same dataset.&amp;nbsp; Aliases are used most when data is merged (joined per SQL).&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-a-computed-variable-into-data-set/m-p/495196#M130650</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-13T08:33:51Z</dc:date>
    </item>
  </channel>
</rss>

