Date: Fri, 20 Jul 2007 09:17:04 -0400
Reply-To: Paul Bartells <paul.bartells@TXU.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Bartells <paul.bartells@TXU.COM>
Subject: Re: Please help with these qns
On Fri, 20 Jul 2007 11:46:12 +0800, VORA Mihir <VORAM@ESSILOR.COM.SG> wrote:
>Hi Rachna,
>
>Below are the answers to your questions:
>
>1) A. 5 DOG
>
>Explanation: value of amount is changed after the if statement so the new
>value of 5 comes in place of 7.
>
>2) B. 12
>
>Explanation: As you are trying to find the value of "i" and the find
>function being case sensitive it searches for the first occurrence of small
>"i" and ignores the first capital "I" in the string. It returns the
position
>of the "i" of ireland and thus returns 12.
>
>3) D. . (Missing value)
>
>Explanation: According to the code you should not be even getting the value
>of Sue in your final test dataset. However if we add an @ after the first
>input line or have truncover after the infile line then Sue's age value
>would be 3 or 0 respectively. However as 3 or 0 is not an option I guess
the
>best or the closest answer would be D. . (Missing value)
>
>HTH,
>Mihir Vora
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>rachna.gollamudi@gmail.com
>Sent: Friday, July 20, 2007 11:03 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Please help with these qns
>
>1. data work.new;
>length word $7;
>amount=7;
>if amount = 5 then word='CAT';
>if amount = 7 then word='DOG';
>else word = 'NONE!!!';
>amount=5;
>run;
>
>WHICH ONE OF THE FOLLOWING REPRESENTS THE VALUES OF AMOUNT AND WORD
>VARIABLES?
>A. 5 DOG
>B. 5 CAT
>C. 7 DOG
>D. 7 (MISSING CHARAC VALUE)
>
>
>2. Data Combine;
> Country = 'Italy, Russia, ireland;
>Found = find (country,'i');
>run;
>
>What is the value of the variable Found?
>
>A. 1
>B. 12
>C. RUSSIA
>D. ITALY
>
>3. The contents of the raw data file EMPLOYEE are listed below:
>ruth 39 11
>jose 32 22
>sue 30 33
>john 40 44
>The following SAS program is submitted
>data test;
>infile 'employee';
>input employee_name $1-4;
>if employee_name='sue' then input age 7-8;
>else input idnum 10-11;
>run;
>which one of the following values does the variable AGE contain when
>the name of the employee is 'Sue';?
>
>
>Answer:
>A. 30
>B. 33
>C. 40
>D. .(missing numeric value)
Vora,
Since you saw fit to attempt to answer the questions, I must take issue
with some of your answers.
Question 1 is fine.
Question 2, however, is not. As submitted, the code will not work due to a
missing quote at the end of the Country string assignment. Therefore, the
FIND function will never be seen.
Question 3 had the correct answer, but for the wrong reason. True, a
trailing @ sign is needed on the input statement. But even with that the
code will not find 'Sue' because the input had 'sue' (lower case). The
input statement also looks strange. I believe a space is required between
the character designator and the column range (e.g., $ 1-4 instead of $1-4).
Still, Howard's response is the best one. Don't ask this group to do your
homework for you. But with any submission, make sure it's typed correctly
if you hope to get reliable assistance.
Regards,
Paul Bartells
TXU Energy
Dallas TX
|