<?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 add a new column to a dataset in data plan's code transform? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610807#M18155</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was it. Interesting paradigm. I was thinking like C# or most other programming languages where you don't have to put the only statement of a THEN branch in a block.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another misconception of mine is that in my code, I expected Laboratory_Renamed to be the new column but it was simply treated as an assignment and ignored. _renamed was instead the column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the final version working version:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
  /* Set the input set */
  set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
  length Laboratory_Renamed $50;
  if LabName = 'WESTERN PATHOLOGY CONSULTANTS' then
    Laboratory_Renamed = 'RENO';
  else Laboratory_Renamed = LabName;
  /*Laboratory_Renamed = _renamed;*/
    /* END data step run */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: Note to self: learn to program in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2019 19:26:17 GMT</pubDate>
    <dc:creator>thebugslayer</dc:creator>
    <dc:date>2019-12-10T19:26:17Z</dc:date>
    <item>
      <title>How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610796#M18150</link>
      <description>&lt;DIV&gt;&lt;FONT&gt;Hello. Don't ask me how I landed on SAS, but it's now on my plate so I am learning...&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;In my data plan, I am trying need to add a column to an existing dataset. The way I found to do it is by adding a column in a code transform. However, I am struggling to create a variable then assign that variable to the new column. I have looked at a few articles and I feel I am pretty close. As a matter of fact one of the iterations worked but I did not save it before. The error I am getting with this code is:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;The action was not successful&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Expecting an arithmetic operator.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Statement is not valid or it is used out of proper order.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Expecting an arithmetic operator.&amp;nbsp; (occurred 16 times)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Syntax error, statement will be ignored.&amp;nbsp; (occurred 16 times)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Statement is not valid or it is used out of proper order.&amp;nbsp; (occurred 16 times)&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Here is my code:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
  /* Set the input set */
  set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
  length _renamed $50;
  if LabName = 'WESTERN PATHOLOGY CONSULTANTS' THEN
    _renamed = 'RENO' ELSE _renamed = LabName;
  "Laboratory_Renamed" = _renamed;
    /* END data step run */
run;&lt;/CODE&gt;
&lt;BR /&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;What am I doing wrong?&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Once the column is added, what happens the next time I run the data plan, is it dropped and recreated automatically?&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Thank you!&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA), Training HOTT cert SQL Server 2012 Business Intelligence (SSIS, SSAS).&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610796#M18150</guid>
      <dc:creator>thebugslayer</dc:creator>
      <dc:date>2019-12-10T18:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610799#M18151</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your trying to assign values for _renamed to a new column then you must have the statement as :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Laboratory_Renamed = _renamed;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you put something in quotes, that means your assigning a string value to the variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610799#M18151</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-12-10T18:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610800#M18152</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83078"&gt;@SuryaKiran&lt;/a&gt; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fixed the line but I still am getting&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;The action was not successful&lt;BR /&gt;ERROR: Expecting an arithmetic operator.&lt;BR /&gt;ERROR: Syntax error, statement will be ignored.&lt;BR /&gt;ERROR: Expecting an arithmetic operator.&amp;nbsp; (occurred 16 times)&lt;BR /&gt;ERROR: Syntax error, statement will be ignored.&amp;nbsp; (occurred 16 times)&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610800#M18152</guid>
      <dc:creator>thebugslayer</dc:creator>
      <dc:date>2019-12-10T18:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610801#M18153</link>
      <description>&lt;P&gt;I think you need a semicolon before the ELSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
  /* Set the input set */
  set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
  length _renamed $50;
  if LabName = 'WESTERN PATHOLOGY CONSULTANTS' THEN
    _renamed = 'RENO'; 
  ELSE _renamed = LabName;
  Laboratory_Renamed = _renamed;
    /* END data step run */
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610801#M18153</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-12-10T18:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610807#M18155</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was it. Interesting paradigm. I was thinking like C# or most other programming languages where you don't have to put the only statement of a THEN branch in a block.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another misconception of mine is that in my code, I expected Laboratory_Renamed to be the new column but it was simply treated as an assignment and ignored. _renamed was instead the column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the final version working version:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
  /* Set the input set */
  set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
  length Laboratory_Renamed $50;
  if LabName = 'WESTERN PATHOLOGY CONSULTANTS' then
    Laboratory_Renamed = 'RENO';
  else Laboratory_Renamed = LabName;
  /*Laboratory_Renamed = _renamed;*/
    /* END data step run */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: Note to self: learn to program in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 19:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610807#M18155</guid>
      <dc:creator>thebugslayer</dc:creator>
      <dc:date>2019-12-10T19:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column to a dataset in data plan's code transform?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610811#M18156</link>
      <description>&lt;P&gt;Welcome to SAS!&amp;nbsp; Here, we get paid by the semicolon --- so bring them on!&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 19:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-add-a-new-column-to-a-dataset-in-data-plan-s-code/m-p/610811#M18156</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-12-10T19:45:01Z</dc:date>
    </item>
  </channel>
</rss>

