<?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 Creating New Variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837936#M36203</link>
    <description>&lt;P&gt;I am trying to figure out what I did wrong. I used the if, then statements to create a new variable "pubertal".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
data bone;
set hw5.bone (where =(sex=1));
age = (dov-dob)/365.25;
if tanner = '1' then pubertal = 0; 
else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0; 
if tanner = '4' then pubertal = 1; 
else if tanner = '5' then pubertal = 1;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;78   libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
NOTE: Libref HW5 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5
79   data bone;
80   set hw5.bone (where =(sex=1));
81   age = (dov-dob)/365.25;
82   if tanner = '1' then pubertal = 0;
83   else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0;
                                                            ----
                                                            388
                                                            202
ERROR 388-185: Expecting an arithmetic operator.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

84   if tanner = '4' then pubertal = 1;
85   else if tanner = '5' then pubertal = 1;
86   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      82:13   83:18   83:52   84:13   85:18
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.BONE may be incomplete.  When this step was stopped there were 0
         observations and 11 variables.
WARNING: Data set WORK.BONE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 11 Oct 2022 20:25:37 GMT</pubDate>
    <dc:creator>MisterJenn</dc:creator>
    <dc:date>2022-10-11T20:25:37Z</dc:date>
    <item>
      <title>Creating New Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837936#M36203</link>
      <description>&lt;P&gt;I am trying to figure out what I did wrong. I used the if, then statements to create a new variable "pubertal".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
data bone;
set hw5.bone (where =(sex=1));
age = (dov-dob)/365.25;
if tanner = '1' then pubertal = 0; 
else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0; 
if tanner = '4' then pubertal = 1; 
else if tanner = '5' then pubertal = 1;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;78   libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
NOTE: Libref HW5 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5
79   data bone;
80   set hw5.bone (where =(sex=1));
81   age = (dov-dob)/365.25;
82   if tanner = '1' then pubertal = 0;
83   else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0;
                                                            ----
                                                            388
                                                            202
ERROR 388-185: Expecting an arithmetic operator.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

84   if tanner = '4' then pubertal = 1;
85   else if tanner = '5' then pubertal = 1;
86   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      82:13   83:18   83:52   84:13   85:18
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.BONE may be incomplete.  When this step was stopped there were 0
         observations and 11 variables.
WARNING: Data set WORK.BONE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 11 Oct 2022 20:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837936#M36203</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-11T20:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837938#M36205</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if tanner = '2'  or tanner = '3' then pubertal = 0; 
else if tanner in ('2', '3') then pubertal=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ELSE statement has too many THEN portions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two options above for working on this are options you can use.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;EDIT:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If numeric, your code should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
data bone;
set hw5.bone (where =(sex=1));
age = (dov-dob)/365.25;
if tanner in (1, 2, 3) then pubertal = 0; 
else if tanner in (4, 5) then pubertal = 1; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Generally not a good idea to use multiple IF/THEN constructs to create the same variable. That's a good way to add bugs to your code.&lt;/LI&gt;
&lt;LI&gt;Use IN instead of multiple IF's&amp;nbsp; or OR to make code legible&lt;/LI&gt;
&lt;LI&gt;Consider using the built in function to calculate Age, unless you want the decimal portion.&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/435394"&gt;@MisterJenn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to figure out what I did wrong. I used the if, then statements to create a new variable "pubertal".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
data bone;
set hw5.bone (where =(sex=1));
age = (dov-dob)/365.25;
if tanner = '1' then pubertal = 0; 
else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0; 
if tanner = '4' then pubertal = 1; 
else if tanner = '5' then pubertal = 1;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;78   libname hw5'\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5';
NOTE: Libref HW5 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Documents\Assignment 5
79   data bone;
80   set hw5.bone (where =(sex=1));
81   age = (dov-dob)/365.25;
82   if tanner = '1' then pubertal = 0;
83   else if tanner = '2' then pubertal = 0 or tanner = '3' then pubertal = 0;
                                                            ----
                                                            388
                                                            202
ERROR 388-185: Expecting an arithmetic operator.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

84   if tanner = '4' then pubertal = 1;
85   else if tanner = '5' then pubertal = 1;
86   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      82:13   83:18   83:52   84:13   85:18
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.BONE may be incomplete.  When this step was stopped there were 0
         observations and 11 variables.
WARNING: Data set WORK.BONE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 20:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837938#M36205</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-11T20:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837939#M36206</link>
      <description>&lt;P&gt;Are you sure that your Tanner variable is character? It appears that every comparison you have involving Tanner is creating the "converted to numeric" warning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such inattention to details can cause lots of issues further on.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 20:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-New-Variables/m-p/837939#M36206</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-11T20:40:36Z</dc:date>
    </item>
  </channel>
</rss>

