<?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: adding new data to existing variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/691192#M24819</link>
    <description>&lt;P&gt;Thank you so much Mark! that helped a lot.&lt;/P&gt;&lt;P&gt;But now when I try to add additional data my IF-THEN statement refuses to work. This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA newperiod;&lt;/P&gt;&lt;P&gt;IF ID=200 then do periodID=1, 2, 3;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else IF ID=200 AND periodID=1 then do;&lt;/P&gt;&lt;P&gt;kidperiodstart=150;&lt;/P&gt;&lt;P&gt;kidperiodend=350;&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;else output;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The AND statement is not highlighted, how do I get this to work?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 10:25:08 GMT</pubDate>
    <dc:creator>Qvika</dc:creator>
    <dc:date>2020-10-13T10:25:08Z</dc:date>
    <item>
      <title>adding new data to existing variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/690974#M24806</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add new observations in my data set in an existing variable, but it does not seem to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable called ID (identification number) and a variable called periodID (1-5), so I can add different periods per ID. Some ID's only have 1 periodID line where I would like to have 2 or 3, but I can't seem to add more lines (called periodID 2 and periodID 3). I am working from a pre-existing work.query. So I tried to make a new data set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA newperiod;&lt;/P&gt;&lt;P&gt;SET oldperiod;&lt;/P&gt;&lt;P&gt;IF ID=200 THEN periodID=1, 2, 3;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me an error. Does somebody know how to fix this problem?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 13:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/690974#M24806</guid>
      <dc:creator>Qvika</dc:creator>
      <dc:date>2020-10-12T13:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: adding new data to existing variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/690978#M24808</link>
      <description>&lt;P&gt;It looks to me like you want to create a new table named &lt;STRONG&gt;newperiod&lt;/STRONG&gt;&amp;nbsp;which contains all of the original rows of data from &lt;STRONG&gt;oldperiod&lt;/STRONG&gt;, but includes additional rows for ID 200. If that's the goal, you'll need to use a conditional DO loop with a explicit OUTPUT statements to control when rows get written to &lt;STRONG&gt;newperiod&lt;/STRONG&gt;. Something like this should do the tirck:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create some test data to play with */&lt;BR /&gt;data oldperiod;
   infile datalines truncover;
   input ID PeriodID;
datalines;
100 1
100 2
200 
300 1
300 2
300 3
400 1
400 2
500 1
;
&lt;BR /&gt;/* Add extra rows for ID # 200 */
data newperiod;
   set oldperiod;
   if ID=200 then do periodID=1, 2, 3;
      output;
   end;
   else output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May the SAS be with you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Mark&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 13:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/690978#M24808</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-10-12T13:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: adding new data to existing variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/691192#M24819</link>
      <description>&lt;P&gt;Thank you so much Mark! that helped a lot.&lt;/P&gt;&lt;P&gt;But now when I try to add additional data my IF-THEN statement refuses to work. This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA newperiod;&lt;/P&gt;&lt;P&gt;IF ID=200 then do periodID=1, 2, 3;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else IF ID=200 AND periodID=1 then do;&lt;/P&gt;&lt;P&gt;kidperiodstart=150;&lt;/P&gt;&lt;P&gt;kidperiodend=350;&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;else output;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The AND statement is not highlighted, how do I get this to work?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 10:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-new-data-to-existing-variable/m-p/691192#M24819</guid>
      <dc:creator>Qvika</dc:creator>
      <dc:date>2020-10-13T10:25:08Z</dc:date>
    </item>
  </channel>
</rss>

