<?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 create a new variable from values of previous variables that meet certain conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476293#M122546</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20421"&gt;@Gjax21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a new variable by dividing the values of single variable "SNinner_SNouter" where another variable has a values of '8' by that same variable "&lt;SPAN&gt;SNinner_SNouter" where that same other variable has a value of 19.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I feel like i need some statement like&amp;nbsp; &amp;nbsp; new var = "SNinner_SNouter" where value is 8&amp;nbsp; &amp;nbsp; /&amp;nbsp; &amp;nbsp;&amp;nbsp;"SNinner_SNouter" where value is&amp;nbsp;19&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have attached the dataset. I appologise that my explanation is probably terrible. I'm not experienced at programming.&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain more clearly what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the values you need to work with already appear on the same observation (or ROW if you are looking at your spreadsheet)?&lt;/P&gt;
&lt;P&gt;If not how do you know which observations to combine so that the values ARE on the same observation?&amp;nbsp; Is there an id variable that would let you merge the observations together?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to compare to the value on the previous observation?&amp;nbsp; Again what are the id variables and is the data already sorted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post small sample data with minimal set of variables and observations to demonstrate the issue.&amp;nbsp; Please post in the form of a data step that can be used to create the dataset.&amp;nbsp; Not a copy of a spreadsheet.&lt;/P&gt;</description>
    <pubDate>Sun, 08 Jul 2018 16:30:59 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-07-08T16:30:59Z</dc:date>
    <item>
      <title>How to create a new variable from values of previous variables that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476290#M122544</link>
      <description>&lt;P&gt;I am trying to create a new variable by dividing the values of single variable "SNinner_SNouter" where another variable has a values of '8' by that same variable "&lt;SPAN&gt;SNinner_SNouter" where that same other variable has a value of 19.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I feel like i need some statement like&amp;nbsp; &amp;nbsp; new var = "SNinner_SNouter" where value is 8&amp;nbsp; &amp;nbsp; /&amp;nbsp; &amp;nbsp;&amp;nbsp;"SNinner_SNouter" where value is&amp;nbsp;19&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have attached the dataset. I appologise that my explanation is probably terrible. I'm not experienced at programming.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jul 2018 15:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476290#M122544</guid>
      <dc:creator>Gjax21</dc:creator>
      <dc:date>2018-07-08T15:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable from values of previous variables that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476293#M122546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20421"&gt;@Gjax21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a new variable by dividing the values of single variable "SNinner_SNouter" where another variable has a values of '8' by that same variable "&lt;SPAN&gt;SNinner_SNouter" where that same other variable has a value of 19.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I feel like i need some statement like&amp;nbsp; &amp;nbsp; new var = "SNinner_SNouter" where value is 8&amp;nbsp; &amp;nbsp; /&amp;nbsp; &amp;nbsp;&amp;nbsp;"SNinner_SNouter" where value is&amp;nbsp;19&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have attached the dataset. I appologise that my explanation is probably terrible. I'm not experienced at programming.&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to explain more clearly what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the values you need to work with already appear on the same observation (or ROW if you are looking at your spreadsheet)?&lt;/P&gt;
&lt;P&gt;If not how do you know which observations to combine so that the values ARE on the same observation?&amp;nbsp; Is there an id variable that would let you merge the observations together?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to compare to the value on the previous observation?&amp;nbsp; Again what are the id variables and is the data already sorted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post small sample data with minimal set of variables and observations to demonstrate the issue.&amp;nbsp; Please post in the form of a data step that can be used to create the dataset.&amp;nbsp; Not a copy of a spreadsheet.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jul 2018 16:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476293#M122546</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-08T16:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable from values of previous variables that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476301#M122552</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ratios;

input Date_of_Experiment$ Global_Timepoint    SNinner_SNouter ;     

cards;

2_15 8 0.99789
2_15 19 1.00253
2_18 8 1.07797
2_18 19 1.10799
2_20 8 0.9677
2_20 19 0.9748
2_27 8 1.08788
2_27 19 1.08133
;;;;;run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The experimental case is indicated by Date_of_Experiment. Global timepoint indicates a numerical designation of a point in time that corresponds to an experimental change. Within each experimental case indicated by "Date_of_Experiment" I want to divide the value of &lt;SPAN&gt;SNinner_SNouter&amp;nbsp; at timepoint 19 by the value at timepoint 8 and write&amp;nbsp;the result as a new variable for each experimental case. As you can see the problem is that they are in different rows.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jul 2018 18:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476301#M122552</guid>
      <dc:creator>Gjax21</dc:creator>
      <dc:date>2018-07-08T18:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable from values of previous variables that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476308#M122553</link>
      <description>&lt;P&gt;You can use the LAG function, or you can simply re-arrange the data as follows. Both assume the data is properly sorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    merge ratios(where=(global_timepoint=8) rename=(SNinner_SNouter=SN8))
        ratios(where=(global_timepoint=19) rename=(SNinner_SNouter=SN19));
    by date_of_experiment;
    ratio = SN19 / SN8;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jul 2018 19:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476308#M122553</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-08T19:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable from values of previous variables that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476345#M122578</link>
      <description>&lt;P&gt;Thanks very much Paige!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This worked very well once I sorted the data. I did not have much luck trying to figure out how to do it by googling. Quick and efficient.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 03:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-from-values-of-previous-variables/m-p/476345#M122578</guid>
      <dc:creator>Gjax21</dc:creator>
      <dc:date>2018-07-09T03:34:29Z</dc:date>
    </item>
  </channel>
</rss>

