<?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 two new variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427601#M105506</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by case_id;
if first.case_id then do;
Yearsbeingunemployed=0;
Yearsbeingemployed=0;
end;
if 	Employmentstatus=1 then  Yearsbeingemployed+1;
else if  Employmentstatus=2 then  Yearsbeingunemployed+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 Jan 2018 04:55:03 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-15T04:55:03Z</dc:date>
    <item>
      <title>Create two new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427598#M105504</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;Hello everyone!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;I have two variables and I want to add two new variables. One of the variables that exist is the employment status of the study participants (1=employed, 2= unemployed) and the other is the year that the participant answered the employment question. I want to make a third variable that indicates the number of years each person was employed. Similarly, I intend to add a fourth&amp;nbsp;variable that cumulatively adds up the years of unemployment and illustrates it for each&amp;nbsp;year. For example, Case ID 1003 was unemployed in 1984, then was employed in the years of 1985 to 1987 (3 years) and again was unemployed in 1988. Hence, in the year of 1988, she had been unemployed for two years and employed for three years.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;I was wondering if you could please help me with programming these new variables? I have also attached a sample data pdf file. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;Thank you for your consideration.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 04:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427598#M105504</guid>
      <dc:creator>Sinakian1</dc:creator>
      <dc:date>2018-01-15T04:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create two new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427600#M105505</link>
      <description>&lt;P&gt;I can't and am not allowed to open attachments. Can you please paste your sample HAVE and sample WANT as text. Also, explain the logic in neat bullet points rather than long sentences. Just my 2 cents. Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 04:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427600#M105505</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-15T04:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create two new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427601#M105506</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by case_id;
if first.case_id then do;
Yearsbeingunemployed=0;
Yearsbeingemployed=0;
end;
if 	Employmentstatus=1 then  Yearsbeingemployed+1;
else if  Employmentstatus=2 then  Yearsbeingunemployed+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2018 04:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427601#M105506</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-15T04:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create two new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427622#M105512</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Post test data in the form of a datastep using the code window (its the {i} above the post area).&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;Also show what the output should look like.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427622#M105512</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-15T09:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create two new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427898#M105585</link>
      <description>&lt;P&gt;Thank you indeed. It worked exactly as I wanted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 00:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-two-new-variables/m-p/427898#M105585</guid>
      <dc:creator>Sinakian1</dc:creator>
      <dc:date>2018-01-16T00:21:26Z</dc:date>
    </item>
  </channel>
</rss>

