Dear Readers, Welcome to SAS Programing Interview Questions and Answers have been designed specially to get you acquainted with the nature of questions you may encounter during your Job interview for the subject of SAS Programing. These SAS Programing Questions are very important for campus placement test and job interviews. As per my experience good interviewers hardly plan to ask any particular questions during your Job interview and these model questions are asked in the online technical test and interview of many IT companies.
A) BASE, STAT, GRAPH, ETSBriefly
A) Match Merging, Direct Access, Format Tables, Arrays, PROC SQL
A) SAS 9.1.3,9.0, 8.2 in Windows and UNIX, SAS 7 and 6.12
A) Sampling method using OBS option or subsetting, commenting the Lines, Use Data Null
A) The result of any operation with missing value will result in missing value. Most SAS statistical procedures exclude observations with any missing variable values from an analysis.
A) Using PROC TRANSPOSE
A) Proc can be used with wider scope and the results can be sent to a different dataset. Functions usually affect the existing datasets.
A) Declare array for number of variables in the record and then used Do loop Proc Transpose with VAR statement
A) It implies that automatic conversion took place to make character functions possible.
A) Because POINT= reads only the specified observations, SAS cannot detect an end-of-file condition as it would if the file were being read sequentially.
A) FIRSTOBS and OBS option
A) 31st December 1961
A) INPUT, DATA and RUN…
A) When SAS editor looks at Run it starts compiling the data or proc step, if you have more than one data step or proc step or if you have a proc step. Following the data step then you can avoid the usage of the run statement.
A) SAS is considered self documenting because during the compilation time it creates and stores all the information about the data set like the time and date of the data set creation later No. of the variables later labels all that kind of info inside the dataset and you can look at that info using proc contents procedure.
A) Sort them once, can use firstobs = and obs = ,
A) Functions can used inside the data step and on the same data set but with proc's you can create a new data sets to output the results. May be more ...........
18. If you were told to create many records from one record, show how you would do this using arrays and with PROC TRANSPOSE?
A) I would use TRANSPOSE if the variables are less use arrays if the var are more ................. depends
A) In unsorted data you can't use First. or Last.
A) First thing is look into Log for errors or warning or NOTE in some cases or use the debugger in SAS data step.
A) Check the Log and for data validation things like Proc Freq, Proc means or some times proc print to look how the data looks like ........
A) I think sort them with common variables and use merge statement. I am not sure what you mean different structures.
A) Will either read or writes all numeric and character variables in dataset.
A) The retain statement is used to hold the values of variables across iterations of the data step. Normally, all variables in the data step are set to missing at the start of each iteration of the data step. What is the order of evaluation of the comparison operators: + - * / ** ()?A) (), **, *, /, +, -
A) Using Data Null and put statement
A) Using Obs=0 and systems options to trace the program execution in log.
A) It will display the execution of whole program and the logic. It will also display the error with line number so that you can and edit the program.
A) It has only to values, which are 1 for error and 0 for no error.
A) Using Subset functions like IF then Else, Where and Select.
A) When you submit a DATA step, SAS processes the DATA step and then creates a new SAS data set.( creation of input buffer and PDV)
Compilation Phase
Execution Phase
A) SAS/Access only process through the databases like Oracle, SQL-server, Ms-Access etc. SAS/Connect only use Server connection.
A) OPTIONS Statement, Label statement, Keep / Drop statements.
A) The N=PS option creates a buffer in memory which is large enough to store PAGESIZE (PS) lines and enables a page to be formatted randomly prior to it being printed.
A) Proc Sort with nodupkey option, because it will eliminate the duplicate values.
A) The main advantage of version 9 is faster execution of applications and centralized access of data and support.
There are lots of changes has been made in the version 9 when we compared with the version 8. The following are the few:SAS version 9 supports Formats longer than 8 bytes & is not possible with version 8.
Length for Numeric format allowed in version 9 is 32 where as 8 in version 8.
Length for Character names in version 9 is 31 where as in version 8 is 32.
Length for numeric informat in version 9 is 31, 8 in version 8.
Length for character names is 30, 32 in version 8.3 new informats are available in version 9 to convert various date, time and datetime forms of data into a SAS date or SAS time.
•ANYDTDTEW. - Converts to a SAS date value •ANYDTTMEW. - Converts to a SAS time value. •ANYDTDTMW. -Converts to a SAS datetime value.CALL SYMPUTX Macro statement is added in the version 9 which creates a macro variable at execution time in the data step by •
Trimming trailing blanks • Automatically converting numeric value to character.
New ODS option (COLUMN OPTION) is included to create a multiple columns in the output.
A) INPUT function converts character data values to numeric values.
PUT function converts numeric values to character values.EX: for INPUT: INPUT (source, informat)
For PUT: PUT (source, format)
Note that INPUT function requires INFORMAT and PUT function requires FORMAT.
If we omit the INPUT or the PUT function during the data conversion, SAS will detect the mismatched variables and will try an automatic character-to-numeric or numeric-to-character conversion. But sometimes this doesn’t work because $ sign prevents such conversion. Therefore it is always advisable to include INPUT and PUT functions in your programs when conversions occur.
INTNX:
INTNX function advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value. Ex: INTNX(interval,start-from,number-of-increments,alignment)
INTCK: INTCK(interval,start-of-period,end-of-period) is an interval functioncounts the number of intervals between two give SAS dates, Time and/or datetime.
DATETIME () returns the current date and time of day.
DATDIF (sdate,edate,basis): returns the number of days between two dates.
A) The first argument to the MOD function is a numeric, the second is a non-zero numeric; the result is the remainder when the integer quotient of argument-1 is divided by argument-2. The INT function takes only one argument and returns the integer portion of an argument, truncating the decimal portion. Note that the argument can be an expression.
DATA NEW ;
A = 123456 ;
X = INT( A/1000 ) ;
Y = MOD( A, 1000 ) ;
Z = MOD( INT( A/100 ), 100 ) ;
PUT A= X= Y= Z= ;
RUN ;
Result:
A=123456
X=123
Y=456
Z=34
A) DIM: It is used to return the number of elements in the array. When we use Dim function we would have to re –specify the stop value of an iterative DO statement if u change the dimension of the array.
A) To determine the number of missing values that are excluded in a computation, use the NMISS function.
data _null_;
m = . ;
y = 4 ;
z = 0 ;
N = N(m , y, z);
NMISS = NMISS (m , y, z);
run;
The above program results in N = 2 (Number of non missing values) and NMISS = 1 (number of missing values).
A) Just use: missing_values=MISSING(field1,field2,field3);
This function simply returns 0 if there aren't any or 1 if there are missing values.If you need to know how many missing values you have then use num_missing=NMISS(field1,field2,field3);
You can also find the number of non-missing values with non_missing=N (field1,field2,field3);
A) For dataset: Data set name/debugData set: name/stmtchk
For macros: Options:mprint mlogic symbolgen.
A) ODS Trace ON, ODS Trace OFF the trace records.
How would you code a merge that will keep only the observations that have matches from both data sets?
Using "IN" variable option. Look at the following example.
data three;
merge one(in=x) two(in=y);
by id;
if x=1 and y=1;
run;
*or;
data three;
merge one(in=x) two(in=y);
by id;
if x and y;
run;
A) Input data set options are obs, firstobs, where, in output data set options compress, reuse.Both input and output dataset options include keep, drop, rename, obs, first obs.
A) SAS/GRAPH software creates and delivers accurate, high-impact visuals that enable decision makers to gain a quick understanding of critical business issues.