<?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: if/do SAS Practice Exam in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743682#M29257</link>
    <description>&lt;P&gt;Yes the wording definitely threw me for a loop. After looking further you are correct the 79 and 89 are the median but it didnt click very easily at first when I read what was being asked. Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 25 May 2021 19:40:56 GMT</pubDate>
    <dc:creator>JC411911</dc:creator>
    <dc:date>2021-05-25T19:40:56Z</dc:date>
    <item>
      <title>if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743450#M29248</link>
      <description>&lt;P&gt;I am practicing for the base certification and having trouble understanding the ask in Step 3. The answer to this has a if group='A' then kilograms=79 else kilograms=89; I don't understand where or why these values are used. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Question Asked:&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Step 1:&lt;/SPAN&gt;&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;create a temporary data set,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;In this data set, convert all&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;values to upper case.&lt;/LI&gt;&lt;LI&gt;Then keep only observations with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;equal to 'A' or 'B'.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;Step 2:&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Determine the MEDIAN value for the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;variable for each&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&amp;nbsp;(A,B) in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data set. Round MEDIAN to the nearest whole number.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;Step 3:&lt;/FONT&gt;&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;create&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;results.output36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;Ensure that all values for variable&amp;nbsp;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are between 40 and 200, inclusively.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#FF0000"&gt;If the value is missing or out of range, replace the value with the MEDIAN&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value for the respective&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(A,B) calculated in step 2.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Step 1: &lt;BR /&gt;data work.cleandata36;
  set cert.input36;
  group=upcase(group);
  if upcase(group) in ('A','B');
run;

Step 2:&lt;BR /&gt;proc means data=work.cleandata36 median;
class group;
var kilograms;
run;

Step 3:&lt;BR /&gt;data results.output36;
  set cleandata36;
  if Kilograms &amp;lt; 40 &lt;FONT color="#FF0000"&gt;OR&lt;/FONT&gt; Kilograms &amp;gt; 200 then do;
  if group='A' then kilograms=79;
  else kilograms=89; 
end;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 01:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743450#M29248</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-25T01:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743469#M29249</link>
      <description>&lt;P&gt;I don't have access to the certification data (at least not that I know of).&amp;nbsp; What is the median value for Group A?&amp;nbsp; What is the median value for Group B?&amp;nbsp; I assume that those values are 79 and 89, respectively.&amp;nbsp; If one sets a missing value to the median value, then one does not shift a curve one way or another, at least I think that's the idea behind this question.&amp;nbsp; Using the median value is an attempt to avoid skewing the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 04:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743469#M29249</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-25T04:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743471#M29250</link>
      <description>&lt;P&gt;I have no idea where 79 or 89 came from, but I assume they are the expected answer to step2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 3 talks about replacing the value when the current value is either missing or not "valid".&lt;/P&gt;
&lt;P&gt;The wording of the last two parts of step 3 is confusing.&amp;nbsp; The middle line make it look like you were requested to eliminate the observations with such invalid values.&amp;nbsp; If you did that then there would be any need to replace any values.&amp;nbsp; So in that case you should first writes some words describing how you have translated their poorly worded question into something that makes sense and then provide the answer to that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The test : (Kilograms &amp;lt; 40 OR Kilograms &amp;gt; 200 ) will includes values that are too large and values that are too small.&amp;nbsp; Since SAS treats missing values as smaller than any actual value it will also include the missing values.&lt;/P&gt;
&lt;P&gt;So you get to the nested IF/THEN/ELSE statements only when you want to replace the value of KILOGRAMS with the group means.&amp;nbsp; That nested IF/THEN/ELSE group is only testing for GROUP='A' but because in STEP 1 you eliminated any values of GROUP that are not A or B then the ELSE must be those where GROUP='B'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 04:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743471#M29250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-25T04:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743478#M29251</link>
      <description>&lt;P&gt;Elaborating on my earlier answer, here's a program that does I believe everything that they're asking for.&amp;nbsp; It uses the calculated means in the final step where values out of range are replaced with the median values.&amp;nbsp; My data has a median of 79 for Group A and 89 for Group B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a suggestion:&amp;nbsp; You might try running my program and playing with it a bit in order to understand it better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See also the comments in the code, such as they are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME	Cert	'X:\sastemp';
LIBNAME	Results	'X:\sastemp';

**	Step 0	- Load data	**;
data Cert.INPUT36;
	LENGTH	Group	$1;
	
  infile	datalines4	dsd	dlm='09'x;
  input		Group	$
  			Kilograms	
			;
  			
DATALINES4;
A	24
A	54
A	60
A	44
A	84
A	42
A	52
A	72
A	74
A	36
A	38
a	104
a	190
a	180
a	120
a	100
a	128
a	130
a	132
a	134
b	24
b	44
b	60
b	54
b	94
b	52
b	62
b	92
b	84
b	86
b	88
b	84
b	170
b	180
b	120
b	110
b	138
b	140
b	142
b	144
b	52
b	62
b	92
b	90
c	999
d	888
e	777
f	666
;;;;
run;

**	Step 1	- Clean the data	**;
data work.cleandata36;
  set cert.input36;
  group=upcase(group);
  if upcase(group) in ('A','B');
run;

**	Step 2	- Calculate the median save it in a data set named Summary	**;
*ODS TRACE	ON;
ODS	OUTPUT	Summary=Summary;
proc means data=work.cleandata36 median;
	class group;
	var kilograms;
run;
*ODS TRACE	OFF;

**	Step 3	- Populate macro variables containing the calculated median for each group	**;
DATA	_NULL_;
	set		WORK.Summary;
	CALL	SYMPUTX(CATS('Median_', Group), ROUND(Kilograms_Median), 'G');
RUN;

**	Step 4	- Substitute the median values when the actual value is out of range	**;
data results.output36;
	set cleandata36;
	if Kilograms &amp;lt; 40 OR Kilograms &amp;gt; 200 then 
		do;
			if group='A' then 
				kilograms=&amp;amp;Median_A;
			else 
				kilograms=&amp;amp;Median_B; 
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 May 2021 05:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743478#M29251</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-25T05:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743680#M29256</link>
      <description>&lt;P&gt;Thank you very much for your help this definitely helps me understand it better!&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 19:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743680#M29256</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-25T19:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: if/do SAS Practice Exam</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743682#M29257</link>
      <description>&lt;P&gt;Yes the wording definitely threw me for a loop. After looking further you are correct the 79 and 89 are the median but it didnt click very easily at first when I read what was being asked. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 19:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-do-SAS-Practice-Exam/m-p/743682#M29257</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-25T19:40:56Z</dc:date>
    </item>
  </channel>
</rss>

