<?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: numeric variable with multiple character variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/589021#M14857</link>
    <description>it worked!!i i thought the "if" statement will create different variables.but now its clearer.Thank you so much</description>
    <pubDate>Mon, 16 Sep 2019 12:38:21 GMT</pubDate>
    <dc:creator>pinkyloop</dc:creator>
    <dc:date>2019-09-16T12:38:21Z</dc:date>
    <item>
      <title>numeric variable with multiple character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588934#M14841</link>
      <description>&lt;P&gt;Hi all,i need help i am totally new to sas and still trying to figure how things work!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am trying to create a new variable&amp;nbsp; with multiple observation&amp;nbsp; but i keep getting syntax error.&lt;/P&gt;&lt;P&gt;here is what i am trying to solve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;DIV&gt;a new variable called LetterGrade that reports an A if the GPA is&lt;/DIV&gt;&lt;DIV&gt;3.5 or higher, a B is the GPA is greater than equal to 2.5 but less than 3.5, a&lt;/DIV&gt;&lt;DIV&gt;C if the GPA is greater than or equal to 1.5 but less than 2.5, a D ifthe GPA&amp;nbsp; &amp;nbsp;is&lt;DIV&gt;greater than or equal 0.5 but less than 1.5, and an F if the GP is below 0.5&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;data merged.lettergrade;&lt;BR /&gt;set merged.merged;&lt;BR /&gt;lettergrade=(A=(gpa&amp;gt;3.5) B=(gpa 2.5&amp;gt;=3.5) C=(gpa 1.5&amp;gt;=2.5) D=(gpa 0.5&amp;gt;=1.5) F=(gpa&amp;lt;0.5));&lt;BR /&gt;run;&lt;BR /&gt;proc print data=merged.lettergrade;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Sep 2019 04:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588934#M14841</guid>
      <dc:creator>pinkyloop</dc:creator>
      <dc:date>2019-09-16T04:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: numeric variable with multiple character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588939#M14843</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This king of classification problem is solved smoothly by a PROC FORMAT like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value fmt 
		low -&amp;lt; 0.5 = 'F'
		0.5 -&amp;lt; 1.5 = 'D'
		1.5 -&amp;lt; 2.5 = 'C'
		2.5 -&amp;lt; 3.5 = 'B'
		3.5 - high = 'A'
	;
run;

data have;
	do x=0 to 5 by .5;
		output;
	end;
run;

data want;
	set have;
	y=put(x, fmt.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Feel free to ask if you have any questions&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 05:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588939#M14843</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-16T05:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: numeric variable with multiple character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588970#M14847</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290508"&gt;@pinkyloop&lt;/a&gt;&amp;nbsp;Welcome to Community SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Data step needs several IF - THEN conditions. You can't place all together. Here is another way for the beginner.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grade;
input gpa;
datalines;
0.3
3.5
4.0
2.5
1.5
3.2
;
run;

data aa;
   set grade;
   /*lettergrade=(A=(gpa&amp;gt;3.5) B=(gpa 2.5&amp;gt;=3.5) C=(gpa 1.5&amp;gt;=2.5) D=(gpa 0.5&amp;gt;=1.5) F=(gpa&amp;lt;0.5)); */
   if (gpa&amp;gt;3.5) then lettergrade='A';
   else if (gpa&amp;gt;2.5) then lettergrade='B';
   else if (gpa&amp;gt;1.5) then lettergrade='C';
   else if (gpa&amp;gt;0.5) then lettergrade='D';
   else lettergrade='F';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another way is to use SELECT-WHEN switch statement as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bb;
   set grade;
   select;
      when (gpa &amp;gt; 3.5) Lettergrade='A';
      when (gpa &amp;gt; 2.5) Lettergrade='B';
      when (gpa &amp;gt; 1.5) Lettergrade='C';
      when (gpa &amp;gt; 0.5) Lettergrade='D';
      otherwise Lettergrade='F';
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best to learn SAS programming&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 09:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/588970#M14847</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-09-16T09:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: numeric variable with multiple character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/589021#M14857</link>
      <description>it worked!!i i thought the "if" statement will create different variables.but now its clearer.Thank you so much</description>
      <pubDate>Mon, 16 Sep 2019 12:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/589021#M14857</guid>
      <dc:creator>pinkyloop</dc:creator>
      <dc:date>2019-09-16T12:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: numeric variable with multiple character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/589022#M14858</link>
      <description>this looks kind of advanced for me but will save it for when i get to this level.Thank you so much .i appreciate</description>
      <pubDate>Mon, 16 Sep 2019 12:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/numeric-variable-with-multiple-character-variables/m-p/589022#M14858</guid>
      <dc:creator>pinkyloop</dc:creator>
      <dc:date>2019-09-16T12:40:16Z</dc:date>
    </item>
  </channel>
</rss>

