<?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 do I add known constants as a column to a dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780572#M31646</link>
    <description>The dataset is coming from a data set about the surrounding population and their health status. The constant data is the total population estimate by race. The total population estimates by race can be found on google and are used for calculating percentages within that data set.</description>
    <pubDate>Tue, 16 Nov 2021 20:40:05 GMT</pubDate>
    <dc:creator>heyyou1</dc:creator>
    <dc:date>2021-11-16T20:40:05Z</dc:date>
    <item>
      <title>How do I add known constants as a column to a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780561#M31644</link>
      <description>&lt;P&gt;I have a data set that I want to add known constants as a new column to the dataset. The constants are not likely to change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data money;
	infile datalines delimiter=",";
	input name $ return invested;
	datalines;
Joe,10,100
Bob,7,50
Mary,80,1000
;&lt;/PRE&gt;&lt;P&gt;this is the existing dataset, and I now want to add the column `height`. (I know this is silly but its for the question). My current attempt is this:&lt;/P&gt;&lt;PRE&gt;data returns;
    set returns;
        heights(m) = 1.8, 2.1, 1.6;
run;&lt;/PRE&gt;&lt;P&gt;The end result I want is something like this.&lt;/P&gt;&lt;PRE&gt;/* name     | return | invested | height(m)*/
/* ____________________________________________ */
/* Joe      |  10   | 100       |  1.8 */
/* Bob      |   7   | 50        | 2.1 */
/* Mary     | 80    | 50        | 1.6 */&lt;/PRE&gt;&lt;P&gt;how could I do something like that?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780561#M31644</guid>
      <dc:creator>heyyou1</dc:creator>
      <dc:date>2021-11-16T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add known constants as a column to a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780568#M31645</link>
      <description>You would rarely ever process data like that manually. Can you explain your actual situation? Would the data come from a data set, sql, JSON?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780568#M31645</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-16T20:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add known constants as a column to a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780572#M31646</link>
      <description>The dataset is coming from a data set about the surrounding population and their health status. The constant data is the total population estimate by race. The total population estimates by race can be found on google and are used for calculating percentages within that data set.</description>
      <pubDate>Tue, 16 Nov 2021 20:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780572#M31646</guid>
      <dc:creator>heyyou1</dc:creator>
      <dc:date>2021-11-16T20:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add known constants as a column to a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780577#M31647</link>
      <description>&lt;P&gt;Personally, this is what I'd do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data heights;
	infile datalines delimiter=",";
	input name $ height;
	datalines;
Joe,1.8
Bob,2.1
Mary,1.6
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then merge it by name, not a fan of implicit merges based on row positions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=money; by name;
proc sort data=heights; by name;

data combined;
merge money heights;
by name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406768"&gt;@heyyou1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The dataset is coming from a data set about the surrounding population and their health status. The constant data is the total population estimate by race. The total population estimates by race can be found on google and are used for calculating percentages within that data set.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780577#M31647</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-16T20:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add known constants as a column to a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780581#M31648</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406768"&gt;@heyyou1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The dataset is coming from a data set about the surrounding population and their health status. The constant data is the total population estimate by race. The total population estimates by race can be found on google and are used for calculating percentages within that data set.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Let's create an example that more closely matches this description than the code in your original question.&lt;/P&gt;
&lt;P&gt;So you have some data that includes RACE as one of the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input race :$40. var1 var2;
cards;
....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And you have your population data by race.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data population;
  input race :$40. total;
cards;
....
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You then merge it with your dataset that has the population by RACE.&lt;/P&gt;
&lt;P&gt;Now you have the population number on every observation of your original data (at least the ones that have race categories that match).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have population;
  by race;
  calculation1 = var1/total;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 21:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-known-constants-as-a-column-to-a-dataset/m-p/780581#M31648</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-16T21:08:22Z</dc:date>
    </item>
  </channel>
</rss>

