<?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 IF THEN ELSE  in SAS DATA STEP in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774337#M25377</link>
    <description>My apologies. The apostrophe evaded my eyes. it's not in my code.</description>
    <pubDate>Thu, 14 Oct 2021 19:47:37 GMT</pubDate>
    <dc:creator>inquistive</dc:creator>
    <dc:date>2021-10-14T19:47:37Z</dc:date>
    <item>
      <title>How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774329#M25371</link>
      <description>&lt;P&gt;Hi experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a SAS neophyte. I am trying to assign different values to a variable&amp;nbsp; based on other variable values in SAS DATA step. Please do not suggest case when expressions of proc sql(which I already know).&lt;/P&gt;&lt;P&gt;Please point out where my code went wrong and also suggest what I need to do. Appreciate your patience and support in advance. My code&amp;nbsp; looks like this;&lt;/P&gt;&lt;P&gt;Data student;&lt;/P&gt;&lt;P&gt;set list (keep= studentid student_name student_type specialty1 stream specialty2 specialtyType1) ;&lt;BR /&gt;length specialtyType1 $15.;&lt;BR /&gt;specilatyType1 =' ';&lt;BR /&gt;if (student_type IN ('rational', 'hardworking') or (student_type= 'Active' and specialty1 IN ('math', 'science', 'computer science')))&lt;BR /&gt;then specilatyType1=' Stem';&lt;BR /&gt;else specilatyType1= 'Non stem';&lt;/P&gt;&lt;P&gt;end';&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774329#M25371</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-14T19:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774331#M25372</link>
      <description>&lt;P&gt;What's the&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;doing there?&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774331#M25372</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-10-14T19:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774332#M25373</link>
      <description>&lt;P&gt;You have the following line of code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which should be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than that, why do you think anything is wrong? Explain.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774332#M25373</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-14T19:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774336#M25376</link>
      <description>My apologies. the apostrophe evaded my eyes. it's not in my code.</description>
      <pubDate>Thu, 14 Oct 2021 19:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774336#M25376</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-14T19:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774337#M25377</link>
      <description>My apologies. The apostrophe evaded my eyes. it's not in my code.</description>
      <pubDate>Thu, 14 Oct 2021 19:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774337#M25377</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-14T19:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774339#M25378</link>
      <description>&lt;P&gt;You will also want to spell "specialty" consistently.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774339#M25378</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2021-10-14T19:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to  use IF THEN ELSE  in SAS DATA STEP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774343#M25379</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83652"&gt;@inquistive&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi experts,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a SAS neophyte. I am trying to assign different values to a variable&amp;nbsp; based on other variable values in SAS DATA step. Please do not suggest case when expressions of proc sql(which I already know).&lt;/P&gt;
&lt;P&gt;Please point out where my code went wrong and also suggest what I need to do. Appreciate your patience and support in advance. My code&amp;nbsp; looks like this;&lt;/P&gt;
&lt;P&gt;Data student;&lt;/P&gt;
&lt;P&gt;set list (keep= studentid student_name student_type specialty1 stream specialty2 specialtyType1) ;&lt;BR /&gt;length specialtyType1 $15.;&lt;BR /&gt;specilatyType1 =' ';&lt;BR /&gt;if (student_type IN ('rational', 'hardworking') or (student_type= 'Active' and specialty1 IN ('math', 'science', 'computer science')))&lt;BR /&gt;then specilatyType1=' Stem';&lt;BR /&gt;else specilatyType1= 'Non stem';&lt;/P&gt;
&lt;P&gt;end';&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When a question like " point out where my code went wrong" arises the first thing to ask, is what did the LOG look like. Copy the entire log including all notes, messages, warnings or erorrs, for the data step or procedure that you think something went wrong with, on the forum open a text box using the &amp;lt;/&amp;gt; icon above the message window and paste the log text into the box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then things like retyped errant apostrophes are not the problem.&lt;/P&gt;
&lt;P&gt;Another possible typing error but if actually in your data different spellings of your variable.&lt;/P&gt;
&lt;PRE&gt;length spe&lt;FONT size="5" color="#0000FF"&gt;&lt;STRONG&gt;cial&lt;/STRONG&gt;&lt;/FONT&gt;tyType1 $15.;
spe&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;cila&lt;/STRONG&gt;&lt;/FONT&gt;tyType1 =' ';&lt;/PRE&gt;
&lt;P&gt;Which defines a length for one variable but the SPECILATY variable will have a length of 1. Then in the later statements you attempt to assign values to the one character length variable:&lt;/P&gt;
&lt;PRE&gt;then specilatyType1=' Stem';
else specilatyType1= 'Non stem';&lt;/PRE&gt;
&lt;P&gt;Spelling counts in programming.&lt;/P&gt;
&lt;P&gt;You should have a note in the Log that variable Speciality is uninitialized. Which if you copy the log as requested we would have seen an pointed out sooner.&lt;BR /&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 20:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-IF-THEN-ELSE-in-SAS-DATA-STEP/m-p/774343#M25379</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-14T20:03:06Z</dc:date>
    </item>
  </channel>
</rss>

