<?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: Insert value into a dataset from another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599706#M173168</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, the first SET statement executes only once, and reads in the historical values only once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, variables read from a SAS data set are automatically retained.&amp;nbsp; So the values just sit there as the second SET statement reads in each observation from the new data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you were advised, try it and see.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will.&lt;/P&gt;
&lt;P&gt;EDIT: Tried and it works. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Oct 2019 16:58:12 GMT</pubDate>
    <dc:creator>jpprovost</dc:creator>
    <dc:date>2019-10-28T16:58:12Z</dc:date>
    <item>
      <title>Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599701#M173163</link>
      <description>&lt;P&gt;Hi fellow experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset containing all the historic (hist_data) informations about a specific kind of data (e.g. mean, min, max, etc.). It all stands in one row and it's updated each month once the latest file is uploaded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, for quality control of my latest data (ex: new_data), I would like to use this row of observations (mean, min, max, etc.) to validate datas in another set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking of creating a new column into new_data with the row of hist_data and to use it as a comparaison variable for each rows that contains new_data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking of creating the new columns in the new_data dataset, but I don't know how to retrieve the data from hist_data into new_data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;hist_data contains:&lt;/P&gt;
&lt;P&gt;mean = 117.8&lt;/P&gt;
&lt;P&gt;min = 112.3&lt;/P&gt;
&lt;P&gt;max = 122.5&lt;/P&gt;
&lt;P&gt;..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add new columns into new_data as is :&lt;/P&gt;
&lt;P&gt;hist_mean = 117.8&lt;/P&gt;
&lt;P&gt;hist_mean = 112.3&lt;/P&gt;
&lt;P&gt;hist_mean = 122.5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And to repeat those observations for each row that contains new_data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do that?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 01:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599701#M173163</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-28T01:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599702#M173164</link>
      <description>&lt;P&gt;Here's one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if _n_=1 then set hist_data (rename=(mean=hist_mean min=hist_min max=hist_max));
set new_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 01:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599702#M173164</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-28T01:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599703#M173165</link>
      <description>But the condition if _n_ = 1 would do it only the line 1?&lt;BR /&gt;I want all those datas to be copied for all rows of new_data...</description>
      <pubDate>Mon, 28 Oct 2019 01:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599703#M173165</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-28T01:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599704#M173166</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/285961"&gt;@jpprovost&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;But the condition if _n_ = 1 would do it only the line 1?&lt;BR /&gt;I want all those datas to be copied for all rows of new_data...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try it and see.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 02:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599704#M173166</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-28T02:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599705#M173167</link>
      <description>&lt;P&gt;Yes, the first SET statement executes only once, and reads in the historical values only once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, variables read from a SAS data set are automatically retained.&amp;nbsp; So the values just sit there as the second SET statement reads in each observation from the new data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you were advised, try it and see.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 02:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599705#M173167</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-28T02:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Insert value into a dataset from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599706#M173168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, the first SET statement executes only once, and reads in the historical values only once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, variables read from a SAS data set are automatically retained.&amp;nbsp; So the values just sit there as the second SET statement reads in each observation from the new data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you were advised, try it and see.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will.&lt;/P&gt;
&lt;P&gt;EDIT: Tried and it works. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 16:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-value-into-a-dataset-from-another-dataset/m-p/599706#M173168</guid>
      <dc:creator>jpprovost</dc:creator>
      <dc:date>2019-10-28T16:58:12Z</dc:date>
    </item>
  </channel>
</rss>

