<?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 use skip observation using if-else statement ? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695404#M25179</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;BR /&gt;Hey, thank you so much for your suggestion !!!&lt;BR /&gt;I had been trying to use the whole variable in the "if" statement and never thought of using only one character in the variable.&lt;BR /&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Fri, 30 Oct 2020 05:39:01 GMT</pubDate>
    <dc:creator>lol123</dc:creator>
    <dc:date>2020-10-30T05:39:01Z</dc:date>
    <item>
      <title>How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695290#M25169</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am a beginner of SAS and I need some urgent helps.&lt;/P&gt;&lt;P&gt;Based on this question, I need to create a SAS data set but I do not know how to proceed with the If-else statement.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (263).png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51219iBD19F0017FCB2E17/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (263).png" alt="Screenshot (263).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This data set&amp;nbsp;&lt;SPAN&gt;consists of a header record for a household and immediately followed by one record for each household member if applicable. If the household doesn't consist of any members, the observation must not be included in the data set.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What should I do in the if-else statement for the program to read the household and its corresponding members into one line of observation? How to ensure that the observation for household without members would be skipped ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems stupid but this is my code and I could not create the data set &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Members;
infile datalines dlm=',';

input houseid :$15. @;
if houseid not in ('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC') then do;
	input type_house: $1. ;
end;	
else if houseid in ('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC') then do;
	input birthdate: date11. hindicator$ gender$ marital$ education employment$ income;
	end;
retain house_id type_house;
datalines;
A1234567BC012,A
15/FEB/1980,Y,Male,Married,3,FT,55000
3/JUN/1982,N,Female,Married,3,UE,0
24/JAN/2005,N,Male,Unknown,2,NA,0
D135EG023456789,B
19/OCT/1950,Y,Female,Divorced,0,PT,5000
X123A567F9,A
B2345234CC,A
21/MAY/1975,N,Male,Married,2,FT,30000
30/JUN/1978,Y,Female,Married,1,PT,10000
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Your helps are much appreciated. Thank you !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 17:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695290#M25169</guid>
      <dc:creator>lol123</dc:creator>
      <dc:date>2020-10-29T17:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695307#M25171</link>
      <description>&lt;P&gt;Apparently all the household id's begin with an uppercase letter.&amp;nbsp; If so, then just read the first character, making sure to have a trailing&amp;nbsp;@ as you do now, in order to prepare for reading of either household or member data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is between 'A' and 'Z' then input household variables.&amp;nbsp; Otherwise do &lt;EM&gt;&lt;STRONG&gt;TWO&lt;/STRONG&gt;&lt;/EM&gt; things: (1) read the member variable, and (2) explicitly output the member record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One caveat.&amp;nbsp; After reading the first character, you should make sure the column pointer is set to column 1 either before or during reading in the household or member variables.&amp;nbsp; That can be done in a couple of ways:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Lead off the household or member variable input statements with "@1".&lt;/LI&gt;
&lt;LI&gt;End the single character read by positioning the pointer at column one, and then ending with the trailing "@".&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 29 Oct 2020 18:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695307#M25171</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-10-29T18:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695315#M25172</link>
      <description>&lt;P&gt;Hello, as pointed out you need to use the trailing @ sign to be able to accomplish this task at the end of the input. Here is an example below of a possible solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carmine&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; Members(drop=frst15chars type_house getmonth);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Length Lhouseid&amp;nbsp; $&lt;STRONG&gt;15&lt;/STRONG&gt; TypeH $&lt;STRONG&gt;1&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Retain Lhouseid TypeH;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; infile datalines&amp;nbsp; dlm=','&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* only execute if there has not been a house id identified*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if lhouseid=" " then do; input&amp;nbsp; frst15chars :$15. @ ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lhouseid=frst15chars;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input type_house: $1. ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TypeH=type_house;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; input&amp;nbsp; frst15chars :$15.&amp;nbsp; @;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; GetMonth=upcase(strip(substr(frst15chars, find(frst15chars,'/')+&lt;STRONG&gt;1&lt;/STRONG&gt;,&lt;STRONG&gt;3&lt;/STRONG&gt;)));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if find("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC",strip(GetMonth),'i') then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; birthdate=input(frst15chars,ANYDTDTE11.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; input&amp;nbsp;&amp;nbsp; hindicator$ gender$ marital$ education employment$ income ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lhouseid=frst15chars;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input type_house: $1.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TypeH=type_house;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;A1234567BC012,A&lt;/P&gt;
&lt;P&gt;15/FEB/1980,Y,Male,Married,3,FT,55000&lt;/P&gt;
&lt;P&gt;3/JUN/1982,N,Female,Married,3,UE,0&lt;/P&gt;
&lt;P&gt;24/JAN/2005,N,Male,Unknown,2,NA,0&lt;/P&gt;
&lt;P&gt;D135EG023456789,B&lt;/P&gt;
&lt;P&gt;19/OCT/1950,Y,Female,Divorced,0,PT,5000&lt;/P&gt;
&lt;P&gt;X123A567F9,A&lt;/P&gt;
&lt;P&gt;B2345234CC,A&lt;/P&gt;
&lt;P&gt;21/MAY/1975,N,Male,Married,2,FT,30000&lt;/P&gt;
&lt;P&gt;30/JUN/1978,Y,Female,Married,1,PT,10000&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 19:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695315#M25172</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2020-10-29T19:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695319#M25173</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;mentioned exactly the right set of issues.&amp;nbsp; However, it's probably a daunting task if you are a beginner in SAS.&amp;nbsp; So here's something that incorporates his suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Members;
infile datalines dlm=',';
input first_char :$1. @1 @;
if ('A' &amp;lt;= upcase(first_char) &amp;lt;= 'Z') then input houseid : $15. type_house : $1.;
else do;
    input birthdate: date11. hindicator$ gender$ marital$ education 
    employment$ income;
   output;
end;
retain house_id type_house;
datalines;
A1234567BC012,A
15/FEB/1980,Y,Male,Married,3,FT,55000
3/JUN/1982,N,Female,Married,3,UE,0
24/JAN/2005,N,Male,Unknown,2,NA,0
D135EG023456789,B
19/OCT/1950,Y,Female,Divorced,0,PT,5000
X123A567F9,A
B2345234CC,A
21/MAY/1975,N,Male,Married,2,FT,30000
30/JUN/1978,Y,Female,Married,1,PT,10000
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Oct 2020 19:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695319#M25173</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-10-29T19:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695404#M25179</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;BR /&gt;Hey, thank you so much for your suggestion !!!&lt;BR /&gt;I had been trying to use the whole variable in the "if" statement and never thought of using only one character in the variable.&lt;BR /&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695404#M25179</guid>
      <dc:creator>lol123</dc:creator>
      <dc:date>2020-10-30T05:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695405#M25180</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22599"&gt;@carmine&lt;/a&gt;&lt;BR /&gt;Hey , thank you for your suggestion !&lt;BR /&gt;I still do not know some of the functions yet, but I will try your suggestion and figure it out !&lt;BR /&gt;Thank you once again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695405#M25180</guid>
      <dc:creator>lol123</dc:creator>
      <dc:date>2020-10-30T05:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use skip observation using if-else statement ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695406#M25181</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;BR /&gt;Hey, thank you for your additional suggestion!!!&lt;BR /&gt;Yes, the task is difficult to me since I only started to learn SAS few weeks ago.&lt;BR /&gt;I will figure out your suggestion !&lt;BR /&gt;Thank you &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-skip-observation-using-if-else-statement/m-p/695406#M25181</guid>
      <dc:creator>lol123</dc:creator>
      <dc:date>2020-10-30T05:44:03Z</dc:date>
    </item>
  </channel>
</rss>

