Вы находитесь на странице: 1из 7

Question: How would you check the uniqueness of a data set? i.e.

that the data set was unique


on its primary key (ID). suppose there were two Identifier variables: ID1, ID2
answer:
1. proc
FREQ
order
tables
shows multiples at top of listing

FREQ;
ID;

2. Or, compare number of obs of original data set and data after
proc
SORT
nodups
or
is
that
proc SORT nodupkey
3. use first.ID in data step to write non-unique to separate data set
if first.ID and last.ID then output UNIQUE; else output DUPS;

Question: How can you avoid using a series of "%INCLUDE" statements?


Answer: Use the Macro Autocall Library.
Question: If you have 2 sets of Format Libraries, can a SAS program have
access to both during 1 session?
Answer: Yes. Use the FMTSEARCH option.
List differences between SAS PROCs and the SAS DATA STEP.
Ans: Procs are sub-routines with a specific purpose in mind and the
data step is designed to read in and manipulate data.

What is SAS?

SAS is an integrated set of software products. The acronym stands for Statistical Analysis System
1.

What is a PDV?

A PDV or Program Data Vector is a logical area in the memory. SAS creates a database of one observation at a
time. At the time of compilation an input buffer is created which holds a record from and external file. The PDV is
created following this input buffer creation.
1.

What is the difference between SAS functions and procedures?

Functions expect values to be supplied across an observation.


Procedures expect one variable value per observation.
Question: Which SAS statement does not perform automatic conversions in comparisons?
Answer: where statement

Question: What would be the result of following SAS function(given that 31 Dec, 2000 is Sunday)?
Weeks = intck (week,31 dec 2000d,01jan2001d);
Years = intck (year,31 dec 2000d,01jan2001d);
Months = intck (month,31 dec 2000d,01jan2001d);
Answer: Weeks=0, Years=1,Months=1
Question: Give some example where PROC REPORTs defaults are different than PROC
PRINTs defaults?
Answer:

No Record Numbers in Proc Report

Labels (not var names) used as headers in Proc Report

REPORT needs NOWINDOWS option

Question: What is the difference between Order and Group variable in proc report?
Answer:

If the variable is used as group variable, rows that have the same values are collapsed.

Group variables produce list report whereas order variable produces summary report.

Question: Give some ways by which you can define the variables to produce the summary
report (using proc report)?

Answer: All of the variables in a summary report must be defined


as group, analysis, across, or

Computed variables.

Questions: What are the default statistics for means procedure?

Answer: n-count, mean, standard deviation, minimum, and maximum

Question: What is the difference between CLASS statement and BY statement in proc
means?
Answer:

Unlike CLASS processing, BY processing requires that your data already be sorted or

indexed in the order of the BY variables.

BY group results have a layout that is different from the layout of CLASS group results.

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
What is the different between functions and PROCs that calculate thesame simple
descriptive statistics?
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.
What is the different between functions and PROCs that calculate the same simple
descriptive statistics?
A) Proc can be used with wider scope and the results can be sent to a different dataset.
Functions usually affect the existing datasets.
If you were told to create many records from one record, show how you would do this
using array and with PROC TRANSPOSE?
A) Declare array for number of variables in the record and then used Do loop Proc Transpose
with VAR statement
Which date functions advances a date time or date/time value by a given interval?
A) INTNX.
What are SAS/ACCESS and SAS/CONNECT?
A) SAS/Access only process through the databases like Oracle, SQL-server, Ms-Access etc.
SAS/Connect only use Server connection.
What is the one statement to set the criteria of data that can be coded in any step?
A) OPTIONS Statement, Label statement, Keep / Drop statements.
What is the purpose of using the N=PS option?
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.

Which date function advances a date, time or datetime value by a given interval?
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-ofincrements,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.
What is the difference between calculating the 'mean' using the mean function and
PROC MEANS?
A) By default Proc Means calculate the summary statistics like N, Mean, Std deviation,
Minimum and maximum, Where as Mean function compute only the mean values.

Which data set is the controlling data set in the MERGE statement?
A) Dataset having the less number of observations control the data set in the merge
statement.
Do you prefer PROC REPORT or PROC TABULATE? Why?
A) I prefer to use Proc report until I have to create cross tabulation tables, because, It gives
me so many options to modify the look up of my table, (ex: Width option, by this we can
change the width of each column in the table) Where as Proc tabulate unable to produce
some of the things in my table. Ex: tabulate doesnt produce n (%) in the desirable format.
What is the difference between nodup and nodupkey options?
A) NODUP compares all the variables in our dataset while NODUPKEY compares just the
BY variables.
What is the main difference between rename and label?
A) 1. Label is global and rename is local i.e., label statement can be used either in proc or
data step where as rename should be used only in data step. 2. If we rename a variable, old
name will be lost but if we label a variable its short name (old name) exists along with its
descriptive name.
What is Enterprise Guide? What is the use of it?
A) It is an approach to import text files with SAS (It comes free with Base SAS version 9.0)
What are input dataset and output dataset options?
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.
How can u create zero observation dataset?
A) Creating a data set by using the like clause.ex: proc sql;create table latha.emp like
oracle.emp;quit;In this the like clause triggers the existing table structure to be copied to the
new table. using this method result in the creation of an empty table.
How can u import .CSV file in to SAS? tell Syntax?
A) To create CSV file, we have to open notepad, then, declare the variables.
proc import datafile='E:\age.csv'
out=sarath dbms=csv replace;
getnames=yes;
run;
What is the use of Proc SQl?
A) PROC SQL is a powerful tool in SAS, which combines the functionality of data and proc
steps. PROC SQL can sort, summarize, subset, join (merge), and concatenate datasets,
create new variables, and print the results or create a new dataset all in one step! PROC
SQL uses fewer resources when compard to that of data and proc steps. To join files in
PROC SQL it does not require to sort the data prior to merging, which is must, is data
merge.
What is SAS GRAPH?
A) SAS/GRAPH software creates and delivers accurate, high-impact visuals that enable
decision makers to gain a quick understanding of critical business issues.

Why is a STOP statement needed for the point=option on a SET statement?


A) When you use the POINT= option, you must include a STOP statement to stop DATA
step processing, programming logic that checks for an invalid value of the POINT= variable,
or Both. Because POINT= reads only those observations that are specified in the DO
statement, SAScannot read an end-of-file indicator as it would if the file were being read
sequentially. Because reading an end-of-file indicator ends a DATA step automatically,
failure to substitute another means of ending the DATA step when you use POINT= can
cause the DATA step to go into a continuous loop.
Question :

Why and How to Use %PUT Statement?

Answer :%Put statement is similar to the PUT statement in data step, What it does is it
writes text and values of macro variable after execution to the SAS System LOG. If you
want to make sure your macro variable resolves as expected, you can make sure it with
%PUT statement.
Unique advantage of %PUT over PUT is you can use %PUT outside the data step
whereas you cannot with PUT.
Question :

Write a macro to split the number of observations in a data-set .

Answer :

%macro split (dsnorig, dsnsplit1, dsnsplit2, obs1);


data &dsnsplit1;
set &dsnorig (obs = &obs1);
run;
data &dsnsplit2;
set &dsnorig (firstobs = %eval(&obs1 + 1));
run;
%mend split;
%split(sasuser.admit,admit4,admit5,2)
Question :

Write a macros for sorting common variables in various data-sets.

Answer :

%macro sortit (datasetname,pid,inverstigator);


PROC SORT DATA = &DATASETNAME;
BY &PID &INVESTIGATOR;
%mend sortit;
%sortit (ae,001,sarath);

What are some of the differences between a WHERE and an IF statement?


Answer: Major differences include:
o IF can only be used in a DATA step
o Many IF statements can be used in one DATA step

o Must read the record into the program data vector to


perform selection with IF
o WHERE can be used in a DATA step as well as a
PROC.
o A second WHERE will replace the first unless the
option ALSO is used
o Data subset prior to reading record into PDV with
WHERE

Question: If you have 2 sets of Format Libraries, can a SAS program


have access to both during 1 session?
Answer: Yes. Use the FMTSEARCH option.

The program data vector (PDV) is a logical block of data that contains the variables used
in a data step or proc step. Variables are added to the program data vector in order of
appearance, and this is what determines their position (or variable number) attribute.

Procedure vs. macro


The question, What is the difference between a procedure and a macro? can catch you off guard
if it has never occurred to you to think of them as having anything in common. It can mystify you
in a completely different way if you have thought of procedures and macros as interchangeable
parts. You might mention:

The difference between generating SAS code, as a macro usually does,


and taking action directly on SAS data, as a procedure usually does

What it means, in terms of efficiency, for a procedure to be a compiled


program

The drastic differences in syntax between a proc step and a macro call

The IMPORT and EXPORT procedures, which with some options


generate SAS statements much like a macro

The %SYSFUNC macro function and %SYSCALL macro statement that


allow a macro to take action directly on SAS data, much like a
procedure

Вам также может понравиться