Thursday, October 4, 2012

SAS Interview Questions 4



126. data samp;
Set emp(keep =a b c d e);
If a=100 then d=50;
Keep a b;
Run; 
How many variable will be written to dataset samp; 
Only a& b
127. data emp;
        Set empd(in=a) emp(in=b);
       If a and b;
     Run;
Assume that a contains 5 and b contains 6 obs. How many records will be written to the o/p dataset emp; 
Ans: 6
128. data _null_;
        A=mdy(10,5,96);
        Put a;
        Run; 
What is the value of a? 
Ans:13427
129. Data _null_;
        Input a;
        Cards;
        $2,345
         ;
What is the value of _error_ in the step?
Ans:1 
130. Which step below is correct?
a) data emp;
Infile cards dlm=’,’;
Input eno ename $;
Cards;
111 suresh
;
b) Data emp dlm=’,’;
Infile cards;
Input eno ename $;
Cards;
111 suresh
Ans: a
131. Which format will display the number 9678 in 9,678 format? 
Ans: comma5.
132. Data  Emp;
        Infile ‘c:\emp.txt’;
        Input @status $3. @;
        If status=’raj’ then
        Then @4 sales comma4. @;
        Else input @4 sales dollar5.@;
        Input predict;
        Run; 
How many records will be read by the above step in one iteration? 
133. proc freq data=emp;
      a. Tables deptno,sal;  
      b. tables deptno sal 
      c. tables deptno;
        d. Tables sal;
      Run; 
134.  Which one below produce tabular o/p.
         Proc freq data=EMP;
a.       Tables detno*sal         
b.      b.  tables deptno,sal
c.        c. tables deptno.sal;
         Run; 
135. data percent(drop=i qtr1-qtr4);
        Set donate;
        Total=sum(of qtr1-qtr2);
        Array conrib{4} qtr1-qtr4;
        Array percent(4);
        Do i=1 to 4;
        Percent (i)=contrib.(i)/total;
        End;
        Run; 
What variables will be created in the o/p dataset? 
Ans: total, percent1,percent2,percent3,percent4.
136. Data  EMP;
        Set emp1;
        Total_sal;
Assume that emp1 has 3 variables
How many variables will be there in the emp after compilation? 
137. Which stmt generate the value 8 in the variable a?
a) a=2*3
b) a=2**3
c) a=3**2
d)none 
138. What is the length of the variable a?
Data emp;
A=’1797’;
Run; 
Ans: 4

139. Data emp1;
        Set EMP;
        Where eno=111;
        Where eno=112; 
Which where stmt will be affected to o/p dataset? 
Last where statement 112
140. Data emp;
        Input eno;
        Cards;
        -123
          ;
What will be the value of eno is the emp; 
Ans: -123
141. Which portion of the dataset will display when we run a PROC PRINT procedure? 
Ans: data portion
142. Data EMP;
        Set EMP;
        By deptno;
        If first .deptno then
        Total+sal;
        If last.deptno;
       Run; 
Ans: totalsal contains sal for each deptno; (in this he has given one more question as no.s like
In one dept 50 emplyees there and out of 50 dept nos how many records will be updated?) 
143. Data EMP;
        Infile ‘c:\sal.txt’ end=eof;
       
        Run; 
Which stmt causes sas to write only the last record into dataset? Ans: eof=1 
144. Data x;
        Length ename $20;
        Infile cards dsd;
        Cards;
        111,”suresh,kumar”,400
        132,”anj,kumar”,300
        
Which step regarding above step is true?
a.   it reads correctly b)it requires dlm c)it won’t read correctly d)syntax error
145. Data summer;
        Set temps;
        If tem>100 then status=’hot’;
        Else status=’cold’;
        Run;
        Temp
         100
         50 
What is the value of status for the second record? Ans: cold
146. Data a;
        Input a b;
        C=a/b;
        Cards;
        10 .
        0 30
        . 12
        14 . 
Values of C in the dataset. 
Ans: .,0,.,.
147. If there is an error in _n_ then what will be the value of the _error_ and
What is the value of it in the next stmt of _n_; 
148. Data gen;
Do i=1 to 6;
Y=x**2;
End;
Run; 
What is the o/p;
Ans: i=7, y=. ,x=. 
149. Data emp;
        Var=’fa’;
        Var1=’1’;
        Var=var||var1;
        Run; 
What is the value of var in o/p dataset? Ans: fa 
150. Which step below is right?
        1) set emp (rename=(eno=empno)(ename=empname));
        2) set emp(rename=(eno=empno ename=empname));
        3) set emp(rename=(eno=empno,ename=empname));

No comments: