<?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: loading same datasets in one data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406844#M99119</link>
    <description>&lt;P&gt;I found reason why it wasn`t working.&lt;/P&gt;&lt;P&gt;Firstly I initialized variable segment by "Produkty kredytowe" which is shorter then "Produkty depozytowe" which results in&lt;/P&gt;&lt;P&gt;segment which I assume should be "Produkty depozytowe" was "Produkty depozytow", that`s why second output datasets remained empty.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2017 08:33:59 GMT</pubDate>
    <dc:creator>Matt3</dc:creator>
    <dc:date>2017-10-24T08:33:59Z</dc:date>
    <item>
      <title>loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406804#M99104</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would be gratefull if anyone could tell me if is it possible to load same dataset&amp;nbsp; twice in one datastep and then output them into two sets ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ve tried code below, but both sets are loaded in the same time which results that second outputed dataset remain empty:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data zb1 zb2;
 set lib.tmp1;
  flg="flg1";
  some operations;
  if flg="flg1" then output zb1;
 set lib.tmp1;
  flg="flg2";
  some operations;
  if flg="flg2" then output zb2;
run;

 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 06:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406804#M99104</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-10-24T06:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406831#M99112</link>
      <description>&lt;P&gt;Why do you want this in one data-steps? This seems to be a bad idea, if "some operations" depends on the flg-variable. If the same operations have to be executed, you could use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data zb1 zb2;
 set lib.tmp1;
  some operations;

  flg="flg1;
  output zb1;
  flg="flg2";
  output zb2;
run;

 


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 07:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406831#M99112</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-10-24T07:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406832#M99113</link>
      <description>&lt;P&gt;Then you do something in your "some operations" that changes flg away from 'flg2'.&lt;/P&gt;
&lt;P&gt;See this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cl1 cl2;
set sashelp.class;
flg = 'flg1';
if flg = 'flg1' then output cl1;
set sashelp.class;
flg = 'flg2';
if flg = 'flg2' then output cl2;
run;

proc print data=cl1 noobs; run;
proc print data=cl2 noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Name       Sex    Age    Height    Weight    flg

Alfred      M      14     69.0      112.5    flg1
Alice       F      13     56.5       84.0    flg1
Barbara     F      13     65.3       98.0    flg1
Carol       F      14     62.8      102.5    flg1
Henry       M      14     63.5      102.5    flg1
James       M      12     57.3       83.0    flg1
Jane        F      12     59.8       84.5    flg1
Janet       F      15     62.5      112.5    flg1
Jeffrey     M      13     62.5       84.0    flg1
John        M      12     59.0       99.5    flg1
Joyce       F      11     51.3       50.5    flg1
Judy        F      14     64.3       90.0    flg1
Louise      F      12     56.3       77.0    flg1
Mary        F      15     66.5      112.0    flg1
Philip      M      16     72.0      150.0    flg1
Robert      M      12     64.8      128.0    flg1
Ronald      M      15     67.0      133.0    flg1
Thomas      M      11     57.5       85.0    flg1
William     M      15     66.5      112.0    flg1
                                                 

Name       Sex    Age    Height    Weight    flg

Alfred      M      14     69.0      112.5    flg2
Alice       F      13     56.5       84.0    flg2
Barbara     F      13     65.3       98.0    flg2
Carol       F      14     62.8      102.5    flg2
Henry       M      14     63.5      102.5    flg2
James       M      12     57.3       83.0    flg2
Jane        F      12     59.8       84.5    flg2
Janet       F      15     62.5      112.5    flg2
Jeffrey     M      13     62.5       84.0    flg2
John        M      12     59.0       99.5    flg2
Joyce       F      11     51.3       50.5    flg2
Judy        F      14     64.3       90.0    flg2
Louise      F      12     56.3       77.0    flg2
Mary        F      15     66.5      112.0    flg2
Philip      M      16     72.0      150.0    flg2
Robert      M      12     64.8      128.0    flg2
Ronald      M      15     67.0      133.0    flg2
Thomas      M      11     57.5       85.0    flg2
William     M      15     66.5      112.0    flg2
&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Oct 2017 07:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406832#M99113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-24T07:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406836#M99114</link>
      <description>I removed another operatios and my code looks excatly like this&lt;BR /&gt;data dostepnosc1 dostepnosc2;&lt;BR /&gt;set dah.nmt;&lt;BR /&gt;segment="Produkty kredytowe";&lt;BR /&gt;&lt;BR /&gt;if segment="Produkty kredytowe" then&lt;BR /&gt;output dostepnosc1;&lt;BR /&gt;set dah.nmt;&lt;BR /&gt;segment="Produkty depozytowe";&lt;BR /&gt;&lt;BR /&gt;if segment="Produkty depozytowe" then&lt;BR /&gt;output dostepnosc2;&lt;BR /&gt;run;&lt;BR /&gt;still no working</description>
      <pubDate>Tue, 24 Oct 2017 08:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406836#M99114</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-10-24T08:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406841#M99116</link>
      <description>&lt;P&gt;"not working" is such an information-rich term, that i don't know where to start to suggest something useful.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 08:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406841#M99116</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-10-24T08:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406842#M99117</link>
      <description>second output dataset remain empty.</description>
      <pubDate>Tue, 24 Oct 2017 08:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406842#M99117</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-10-24T08:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406843#M99118</link>
      <description>&lt;P&gt;Post example data for dah.nmt and the log of the step.&lt;/P&gt;
&lt;P&gt;My previous example is evidence that the basic logic works.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 08:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406843#M99118</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-24T08:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406844#M99119</link>
      <description>&lt;P&gt;I found reason why it wasn`t working.&lt;/P&gt;&lt;P&gt;Firstly I initialized variable segment by "Produkty kredytowe" which is shorter then "Produkty depozytowe" which results in&lt;/P&gt;&lt;P&gt;segment which I assume should be "Produkty depozytowe" was "Produkty depozytow", that`s why second output datasets remained empty.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 08:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406844#M99119</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-10-24T08:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406848#M99122</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127617"&gt;@Matt3&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I found reason why it wasn`t working.&lt;/P&gt;
&lt;P&gt;Firstly I initialized variable segment by "Produkty kredytowe" which is shorter then "Produkty depozytowe" which results in&lt;/P&gt;
&lt;P&gt;segment which I assume should be "Produkty depozytowe" was "Produkty depozytow", that`s why second output datasets remained empty.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good catch. That's why it is always a good idea to explicitly set a sufficient length for newly created variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will end up as a new Maxim.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 08:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406848#M99122</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-24T08:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406877#M99133</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127617"&gt;@Matt3&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Try to understand the sample code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically: You don't need to read the source data set twice. You read it once and then you're doing "stuff" with the data and you write this data to one or multiple target data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What certainly doesn't make any sense in your code:&lt;/P&gt;
&lt;P&gt;1. you assign a value to variable &lt;EM&gt;segment&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;2. you have an if statement which checks for the value which you just assigned - well: that's going to be always TRUE so what's the purpose of this?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 10:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406877#M99133</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-24T10:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406881#M99135</link>
      <description>&lt;P&gt;I do diffrent operations in both datasets that`s why I load them twice.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 10:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406881#M99135</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-10-24T10:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406883#M99136</link>
      <description>&lt;P&gt;If you do not change the original contents, a reload is not necessary.&lt;/P&gt;
&lt;P&gt;if you change the contents, the clean way for doing this is to create new variables for the target datasets, and use keep= and rename= dataset options there if you want the original column names.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 10:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406883#M99136</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-24T10:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: loading same datasets in one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406884#M99137</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127617"&gt;@Matt3&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If you really need to read the source data twice and write the results to two target data sets then there is not much reason to not implement your logic in two data steps. That will result in much cleaner and simpler code without any impact on performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 10:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loading-same-datasets-in-one-data-step/m-p/406884#M99137</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-24T10:47:03Z</dc:date>
    </item>
  </channel>
</rss>

