<?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: Create new variable in new dataset, age value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-in-new-dataset-age-value/m-p/517748#M140045</link>
    <description>&lt;P&gt;There are a few issues here.&amp;nbsp; First, what folder holds the existing data set called chemistry?&amp;nbsp; Is it C:\myfolders ?&amp;nbsp; If so, you would need this statement in your program to identify where the data is coming from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname sasdata "C:\myfolders";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that, sasdata.chemistry would be the proper way to refer to the existing data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what folder do you want to use to store your new data set?&amp;nbsp; If it is going to be the same folder, you would need to identify the new data set as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sasdata.chemistry_new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is going to be some other folder, you need to add an additional LIBNAME statement to identify that other folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, since chemistry is already a SAS data set, SAS knows all the variables it contains.&amp;nbsp; You don't need an INPUT statement to define them.&amp;nbsp; Just remove the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Dec 2018 16:06:32 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-12-01T16:06:32Z</dc:date>
    <item>
      <title>Create new variable in new dataset, age value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-in-new-dataset-age-value/m-p/517745#M140044</link>
      <description>&lt;P&gt;I have to create a library.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then,&amp;nbsp;I have a data called&amp;nbsp;chemistry with 3 variables (name, gender, year_of_birth).&lt;/P&gt;&lt;P&gt;I have to input all the obs and the 3 variables into a new dataset called chemistry_new and store it in the library.&lt;/P&gt;&lt;P&gt;Also, I need to add a new variable named age.&lt;/P&gt;&lt;P&gt;The age variable is the number of years between the student's year of birth and year 2010 (e.g., if y_o_b=1990, then age=2010-1990=20).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have done this but it seems to be wrong..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname libref "C:\myfolders";
data chemistry_new;
set sasdata.chemistry;

input name $ gender $ year_of_birth;
age = 2010-year_of_birth;

run;

 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 15:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-in-new-dataset-age-value/m-p/517745#M140044</guid>
      <dc:creator>kennyA</dc:creator>
      <dc:date>2018-12-01T15:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variable in new dataset, age value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-in-new-dataset-age-value/m-p/517748#M140045</link>
      <description>&lt;P&gt;There are a few issues here.&amp;nbsp; First, what folder holds the existing data set called chemistry?&amp;nbsp; Is it C:\myfolders ?&amp;nbsp; If so, you would need this statement in your program to identify where the data is coming from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname sasdata "C:\myfolders";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that, sasdata.chemistry would be the proper way to refer to the existing data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what folder do you want to use to store your new data set?&amp;nbsp; If it is going to be the same folder, you would need to identify the new data set as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sasdata.chemistry_new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is going to be some other folder, you need to add an additional LIBNAME statement to identify that other folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, since chemistry is already a SAS data set, SAS knows all the variables it contains.&amp;nbsp; You don't need an INPUT statement to define them.&amp;nbsp; Just remove the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 16:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variable-in-new-dataset-age-value/m-p/517748#M140045</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-01T16:06:32Z</dc:date>
    </item>
  </channel>
</rss>

