<?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: How to most efficiently add a variable to very large dataset? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597316#M16137</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yeah. Don't use PUT() function which slow your machine .&lt;/P&gt;
&lt;P&gt;Try to do some math algorithm .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date;
cards;
20191010
20181001
20170707
;

data want;
 set have;
 date_var=mdy(mod(int(date/100),100),mod(date,100),int(date/10000));
 format date_var yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I beg to differ. I ran this comparison test:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date_num = 20191017;
do i = 1 to 10000000;
  output;
end;
run;

data want1;
set have;
date_var = input(put(date_num,best8.),yymmdd8.);
format date_var date9.;
run;

data want2;
 set have;
 date_var = mdy(mod(int(date_num/100),100),mod(date_num,100),int(date_num/10000));
 format date_var yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The put/input variant ran for 5.91 seconds, the more complex method took 6.08, with the time difference mostly in CPU time.&lt;/P&gt;
&lt;P&gt;So at best there's no difference.&lt;/P&gt;
&lt;P&gt;All function calls are CPU intensive.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2019 13:35:37 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-10-17T13:35:37Z</dc:date>
    <item>
      <title>How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/596883#M16038</link>
      <description>&lt;P&gt;I currently have a dataset with over 500,000,000 rows where one of the date variables is in numeric format and needs to be reformatted to a date format as a new variable. My attempt with the following method takes over 12 hours and I was wondering if there was a more efficient method. If it's helpful, the data does contain a 'state' variable with the 50 states in the US if it needs to be subsetted.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
date_var=input(put(date_num,best8.),yymmdd8.);
format date_var date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 13:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/596883#M16038</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-10-16T13:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/596896#M16044</link>
      <description>&lt;P&gt;This is the fastest and most efficient method. Nothing beats a data step when the dataset structure changes. When you monitor your system, you will see that you are (most probably) completely I/O bound, with the CPU being near idle.&lt;/P&gt;
&lt;P&gt;If you regularly have to deal with data of that size, consider ramping up your storage. Like using arrays of SSD's.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 13:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/596896#M16044</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-16T13:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597311#M16135</link>
      <description>&lt;P&gt;Yeah. Don't use PUT() function which slow your machine .&lt;/P&gt;
&lt;P&gt;Try to do some math algorithm .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date;
cards;
20191010
20181001
20170707
;

data want;
 set have;
 date_var=mdy(mod(int(date/100),100),mod(date,100),int(date/10000));
 format date_var yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597311#M16135</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-17T13:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597316#M16137</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yeah. Don't use PUT() function which slow your machine .&lt;/P&gt;
&lt;P&gt;Try to do some math algorithm .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date;
cards;
20191010
20181001
20170707
;

data want;
 set have;
 date_var=mdy(mod(int(date/100),100),mod(date,100),int(date/10000));
 format date_var yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I beg to differ. I ran this comparison test:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date_num = 20191017;
do i = 1 to 10000000;
  output;
end;
run;

data want1;
set have;
date_var = input(put(date_num,best8.),yymmdd8.);
format date_var date9.;
run;

data want2;
 set have;
 date_var = mdy(mod(int(date_num/100),100),mod(date_num,100),int(date_num/10000));
 format date_var yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The put/input variant ran for 5.91 seconds, the more complex method took 6.08, with the time difference mostly in CPU time.&lt;/P&gt;
&lt;P&gt;So at best there's no difference.&lt;/P&gt;
&lt;P&gt;All function calls are CPU intensive.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597316#M16137</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-17T13:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597322#M16140</link>
      <description>&lt;P&gt;Sorry.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know what to say .&lt;/P&gt;
&lt;P&gt;According&amp;nbsp; to sas documentation , PUT() would get you slow , .so I just guess using math function would get faster .&lt;/P&gt;
&lt;P&gt;Let OP do some test on my code . Maybe the beauty is on your side .&amp;nbsp;&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://communities.sas.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597322#M16140</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-17T13:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597323#M16141</link>
      <description>That's unfortunate but good to know. Thanks!</description>
      <pubDate>Thu, 17 Oct 2019 13:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597323#M16141</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-10-17T13:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597330#M16142</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;En, Interesting , under my ugly laptop , I get the different result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="x.png" style="width: 539px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33213i9F4FFF13BC17F4C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="x.png" alt="x.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 14:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597330#M16142</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-17T14:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to most efficiently add a variable to very large dataset?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597352#M16144</link>
      <description>&lt;P&gt;Different CPU architecture might well play a (significant) role here.&lt;/P&gt;
&lt;P&gt;As often, it boils down to Maxim 4.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 14:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-most-efficiently-add-a-variable-to-very-large-dataset/m-p/597352#M16144</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-17T14:46:31Z</dc:date>
    </item>
  </channel>
</rss>

