<?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: Appending new column from IML onto original dataset in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805121#M5800</link>
    <description>&lt;P&gt;The easiest way is to create a new data set that has the new column(s) and then merge with the original data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
ds = "Sashelp.Class";
use (ds);
read all var _NUM_ into X[c=VarNames];
close (ds);

print varNames;

weight = X[,'Weight'];
NewWeight = 2*weight;

create NewCol var "NewWeight";
append;
close;
QUIT;

data newClass;
merge Sashelp.Class NewCol;
run;

proc print data=NewClass; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Mar 2022 18:18:31 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-03-30T18:18:31Z</dc:date>
    <item>
      <title>Appending new column from IML onto original dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805099#M5799</link>
      <description>&lt;P&gt;I am looking to take a column off an existing dataset (Weight in the example below), do logic on it in IML and then add a new column to the existing data set (or create a new dataset with all the columns from the original and the new column).&amp;nbsp; &amp;nbsp;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;ds = "Sashelp.Class";&lt;BR /&gt;use (ds);&lt;BR /&gt;read all var _NUM_ into X;&lt;BR /&gt;close (ds);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...do some vector logic using Weight...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...add the new column vector back onto the original dataset...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 16:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805099#M5799</guid>
      <dc:creator>nicholasbromley</dc:creator>
      <dc:date>2022-03-30T16:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Appending new column from IML onto original dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805121#M5800</link>
      <description>&lt;P&gt;The easiest way is to create a new data set that has the new column(s) and then merge with the original data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
ds = "Sashelp.Class";
use (ds);
read all var _NUM_ into X[c=VarNames];
close (ds);

print varNames;

weight = X[,'Weight'];
NewWeight = 2*weight;

create NewCol var "NewWeight";
append;
close;
QUIT;

data newClass;
merge Sashelp.Class NewCol;
run;

proc print data=NewClass; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2022 18:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805121#M5800</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-03-30T18:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Appending new column from IML onto original dataset</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805218#M5801</link>
      <description>&lt;P&gt;Why not use a table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
  t = TableCreateFromDataSet("Sashelp", "Class");
  NewWeight = TableGetVarData(t, "Weight")#2;
  call TableAddVar(t, "NewWeight", NewWeight);
  call TableWriteToDataSet(t, "work", "NewClass");
quit;
proc print data=NewClass;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 07:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Appending-new-column-from-IML-onto-original-dataset/m-p/805218#M5801</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2022-03-31T07:51:44Z</dc:date>
    </item>
  </channel>
</rss>

