You are on page 1of 35

sample answer 2:

I have been working in the pharmaceutical industry as a SAS professional for more than 5 years.

I have used Base SAS, SAS Macros and Proc SQL to analyze datasets and then generated Tables,
Listings, and Graph’s.

I have generated reports using ODS into formats such as RTF, PDF, and HTML.

I have worked with senior Bio-statisticians and clinical data managers to provide SAS programming in
analyzing the clinical trial data according to the SAP.

I have developed programs in SAS for converting the Oracle Data into SAS datasets using SQL Pass
through facility and Libname facility.

I have also used SAS macros for frequently used programs and developed programs for generating
efficacy and safety tables.

I also involved in validation of my fellow programmer code.I have developed Edit check programs to clean
invalid data from the database.

I worked in both WINDOWS and UNIX environments.

I have worked on Case Report Tabulation section of NDA submission as well.

I was also involved in creating annotated case report form (eCRF) using CDISC-SDTM mapping.

I was involved in creating CRT’s for an NDA electronic submission to the FDA.

I also got Involved in mapping, pooling and analysis of clinical study data for safety and validating and QC
of the efficacy and safety tables.

Sample Answer 3: My answer....

I've been a SAS programmer for 6 years. I'm especially skilled with CDISC guidelines including SDTM
and ADaM.

My recent experience is with XXX company , a CRO in state where I worked as Statistical Programmer on
a number of projects in a variety of drug and medical device areas.
I made a significant contribution to the project recently I have worked on because of my expertise in SAS
Programming and CDISC skills.

I work well even under minimal supervision also I am a team player.

I had an excellent experience in Base SAS/SAS Graph/Proc SQL including the SAS MACRO language.

I also have great deal of experience in creating CRT’s as a part of electronic submission of NDA
application to the FDA.

Now I’m looking for a new opportunity where I can contribute to the growth of the company and have a
positive impact on the programming team.

2.Did you bring your resume?


Yes.
Be prepared with two or three extra copies. Do not offer them unless you’re asked for one.
3.What is your long-range objective?

The key is to focus on your achievable objectives and what you are doing to reach those objectives.

For example: “Within five years, I would like to become one of the best SAS Programmer in the
Pharmaceutical Industry.

I want to work toward becoming the expert that others rely upon. And in doing so, I feel I’ll be fully
prepared to take on any greater responsibilities which might be presented in the long term.For example,
here is what I’m presently doing to prepare myself . . .

”Then go on to show by your examples what you are doing to reach your goals and objectives.

4.Are you a team player?

Teamwork is the key.Almost everyone says yes to this question. But it is not just a yes/no question. You
need to provide behavioral examples to back up your answer.

A sample answer:

“Yes, I’m very much a team player. In fact, I’ve had opportunities in my work, school and athletics to
develop my skills as a team player. For example, on a recent project . . .”Emphasize teamwork behavioral
examples and focus on your openness to diversity of backgrounds. Talk about the strength of the team
above the individual. And note that this question may be used as a lead in to questions around how you
handle conflict within a team, so be prepared You are, of course, a team player.

Be sure to have examples ready. Specifics that show you often perform for the good of the team rather
than for yourself are good evidence of your team attitude. Do not brag, just say it in a matter-of-fact tone.
This is a key point.

5.What is your greatest weakness?

Most career books tell you to select strength and present it as a weakness. Such as: “I work too much. I
just work and work and work.” Wrong.

First of all, using strength and presenting it as a weakness is deceiving.


Second, it misses the point of the question.You should select a weakness that you have been actively
working to overcome.

For example: “I have had trouble in the past with planning and prioritization. However, I’m now taking
steps to correct this. I just started using a pocket planner . . .” then show them your planner and how you
are using it.Talk about a true weakness and show what you are doing to overcome it.

I would say my greatest weakness has been my lack of proper planning in the past. I would over commit
myself with too many variant tasks, then not be able to fully accomplish each, as I would like. However,
since I've come to recognize that weakness, I've taken steps to correct it. For example, I now carry a
planning calendar in my pocket so that I can plan all of my appointments and "to do" items. Here, let me
show you how I have this week planned out...

courtesy: http://web.wenxuecity.com/BBSView.php?SubID=career&MsgID=158267

Tell me about yourself?


Start with the present and tell why you are well qualified for the position. Remember that the
key to all successful interviewing is to match your qualifications to what the interviewer is
looking for. In other words you must sell what the buyer is buying. This is the single most
important strategy in job hunting.

So, before you answer this or any question it's imperative that you try to uncover your
interviewer's greatest need, want, problem or goal.

To do so, make you take these two steps:

Do all the homework you can before the hr interview to uncover this person's wants and needs
(not the generalized needs of the industry or company)

As early as you can in the interview, ask for a more complete description of what the position
entails. You might say: “I have a number of accomplishments I'd like to tell you about, but I want to make
the best use of our time together and talk directly to your needs. To help me do, that, could you tell me
more about the most important priorities of this position? All I know is what I (heard from the recruiter,
read in the classified ad, etc .

Then, ALWAYS follow-up with a second and possibly, third question, to draw out his needs even more.
Surprisingly, it's usually this second or third question that unearths what the interviewer is most looking
for.

You might ask simply, "And in addition to that?..." or, "Is there anything else you see as essential to
success in this position?:

This process will not feel easy or natural at first, because it is easier simply to answer questions,
but only if you uncover the employer's wants and needs will your answers make the most sense.
Practice asking these key questions before giving your answers, the process will feel more
natural and you will be light years ahead of the other job candidates you're competing with.

After uncovering what the employer is looking for, describe why the needs of this job bear
striking parallels to tasks you've succeeded at before. Be sure to illustrate with specific examples
of your responsibilities and especially your achievements, all of which are geared to present
yourself as a perfect match for the needs he has just described.

What are your greatest strengths?

You know that your key strategy is to first uncover your interviewer's greatest wants and needs
before you answer questions.

And from Question 1, you know how to do this.

Prior to any interview, you should have a list mentally prepared of your greatest strengths. You
should also have, a specific example or two, which illustrates each strength, an example chosen
from your most recent and most impressive achievements.

You should, have this list of your greatest strengths and corresponding examples from your
achievements so well committed to memory that you can recite them cold after being shaken
awake at 2:30AM.

Then, once you uncover your interviewer's greatest wants and needs, you can choose those
achievements from your list that best match up.

As a general guideline, the 10 most desirable traits that all employers love to see in their
employees are:

A proven track record as an achiever...especially if your achievements match up with the


employer's greatest wants and needs.

Intelligence...management "savvy".
Honesty...integrity...a decent human being.
Good fit with corporate culture...someone to feel comfortable with...a team player who meshes
well with interviewer's team.
Likeability...positive attitude...sense of humor.
Good communication skills.
Dedication...willingness to walk the extra mile to achieve excellence.
Definiteness of purpose...clear goals.
Enthusiasm...high level of motivation.
Confident...healthy... a leader.

What are your greatest weaknesses?

Disguise strength as a weakness.

Example: “I sometimes push my people too hard. I like to work with a sense of urgency and
everyone is not always on the same wavelength.”

Drawback: This strategy is better than admitting a flaw, but it's so widely used, it is transparent
to any experienced interviewer.

BEST ANSWER: (and another reason it's so important to get a thorough description of your
interviewer's needs before you answer questions): Assure the interviewer that you can think of
nothing that would stand in the way of your performing in this position with excellence. Then,
quickly review you strongest qualifications.

Example: “Nobody's perfect, but based on what you've told me about this position, I believe I' d
make an outstanding match. I know that when I hire people, I look for two things most of all. Do
they have the qualifications to do the job well, and the motivation to do it well? Everything in
my background shows I have both the qualifications and a strong desire to achieve excellence in
whatever I take on. So I can say in all honesty that I see nothing that would cause you even a
small concern about my ability or my strong desire to perform this job with excellence.”
Alternate strategy (if you don't yet know enough about the position to talk about such a perfect
fit):

Instead of confessing a weakness, describe what you like most and like least, making sure that
what you like most matches up with the most important qualification for success in the position,
and what you like least is not essential.

Why are you leaving (or did you leave) this position ?

(If you have a job presently tell the hr)


If you’re not yet 100% committed to leaving your present post, don’t be afraid to say so. Since
you have a job, you are in a stronger position than someone who does not. But don’t be coy
either. State honestly what you’d be hoping to find in a new spot. Of course, as stated often
before, you answer will all the stronger if you have already uncovered what this position is all
about and you match your desires to it.
(If you do not presently have a job tell the hr.)
Never lie about having been fired. It’s unethical – and too easily checked. But do try to deflect
the reason from you personally. If your firing was the result of a takeover, merger, division wide
layoff, etc., so much the better.

But you should also do something totally unnatural that will demonstrate consummate
professionalism. Even if it hurts , describe your own firing – candidly, succinctly and without a
trace of bitterness – from the company’s point-of-view, indicating that you could understand
why it happened and you might have made the same decision yourself.

Your stature will rise immensely and, most important of all, you will show you are healed from
the wounds inflicted by the firing. You will enhance your image as first-class management
material and stand head and shoulders above the legions of firing victims who, at the slightest
provocation, zip open their shirts to expose their battle scars and decry the unfairness of it all.

For all prior positions:


Make sure you’ve prepared a brief reason for leaving. Best reasons: more money, opportunity,
responsibility or growth.

Why should I hire you?


By now you can see how critical it is to apply the overall strategy of uncovering the employer’s
needs before you answer questions. If you know the employer’s greatest needs and desires, this
question will give you a big leg up over other candidates because you will give him better
reasons for hiring you than anyone else is likely to…reasons tied directly to his needs.

Whether your interviewer asks you this question explicitly or not, this is the most important
question of your interview because he must answer this question favorably in is own mind
before you will be hired. So help him out! Walk through each of the position’s requirements as
you understand them, and follow each with a reason why you meet that requirement so well.
Example: “As I understand your needs, you are first and foremost looking for someone who can
manage the sales and marketing of your book publishing division. As you’ve said you need
someone with a strong background in trade book sales. This is where I’ve spent almost all of my
career, so I’ve chalked up 18 years of experience exactly in this area. I believe that I know the
right contacts, methods, principles, and successful management techniques as well as any
person can in our industry.”

“You also need someone who can expand your book distribution channels. In my prior post, my
innovative promotional ideas doubled, then tripled, the number of outlets selling our books. I’m
confident I can do the same for you.”

“You need someone to give a new shot in the arm to your mail order sales, someone who knows
how to sell in space and direct mail media. Here, too, I believe I have exactly the experience you
need. In the last five years, I’ve increased our mail order book sales from $600,000 to
$2,800,000, and now we’re the country’s second leading marketer of scientific and medical
books by mail.” Etc., etc., etc.,
Every one of these selling “couplets” (his need matched by your qualifications) is a touchdown
that runs up your score. IT is your best opportunity to outsell your competition.

Aren’t you overqualified for this position?


As with any objection, don’t view this as a sign of imminent defeat. It’s an invitation to teach the
interviewer a new way to think about this situation, seeing advantages instead of drawbacks.

Example: “I recognize the job market for what it is – a marketplace. Like any marketplace, it’s
subject to the laws of supply and demand. So ‘overqualified’ can be a relative term, depending
on how tight the job market is. And right now, it’s very tight. I understand and accept that.”

“I also believe that there could be very positive benefits for both of us in this match.”
“Because of my unusually strong experience in ________________ , I could start to contribute right away,
perhaps much faster than someone who’d have to be brought along more slowly.”

“There’s also the value of all the training and years of experience that other companies have
invested tens of thousands of dollars to give me. You’d be getting all the value of that without
having to pay an extra dime for it. With someone who has yet to acquire that experience, he’d
have to gain it on your nickel.”

“I could also help you in many things they don’t teach at the Harvard Business School. For
example…(how to hire, train, motivate, etc.) When it comes to knowing how to work well with
people and getting the most out of them, there’s just no substitute for what you learn over
many years of front-line experience. You company would gain all this, too.”

“From my side, there are strong benefits, as well. Right now, I am unemployed. I want to work,
very much, and the position you have here is exactly what I love to do and am best at. I’ll be
happy doing this work and that’s what matters most to me, a lot more that money or title.”

“Most important, I’m looking to make a long term commitment in my career now. I’ve had
enough of job-hunting and want a permanent spot at this point in my career. I also know that if I
perform this job with excellence, other opportunities cannot help but open up for me right here.
In time, I’ll find many other ways to help this company and in so doing, help myself. I really am
looking to make a long-term commitment.”

NOTE: The main concern behind the “overqualified” question is that you will leave your new
employer as soon as something better comes your way. Anything you can say to demonstrate
the sincerity of your commitment to the employer and reassure him that you’re looking to stay
for the long-term will help you overcome this objection.

What do the SAS log messages "numeric values have been converted to character" mean? What
are the implications?

A) It implies that automatic conversion took place to make character functions possible.
Why is a STOP statement needed for the POINT= option on a SET statement?
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.

How do you control the number of observations and/or variables read or written?

A) FIRSTOBS and OBS option

Approximately what date is represented by the SAS date value of 730?


A) 31st December 1961

Identify statements whose placement in the DATA step is critical.


A) INPUT, DATA and RUN…

Does SAS 'Translate' (compile) or does it 'Interpret'? Explain.


A) Compile

What does the RUN statement do?


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.

Why is SAS considered self-documenting?


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.

What are some good SAS programming practices for processing very large data sets?
A) Sort them once, can use firstobs = and obs = ,

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. May be more ...........

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 a method for assigning first.VAR and last.VAR to the BY groupvariable on unsorted data?
A) In unsorted data you can't use First. or Last.

How do you debug and test your SAS programs?


A) First thing is look into Log for errors or warning or NOTE in some cases or use the debugger in SAS
data step.

What other SAS features do you use for error trapping and datavalidation?
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 ........

How would you combine 3 or more tables with different structures?


A) I think sort them with common variables and use merge statement. I am not sure what you mean
different structures.

Other questions:

What areas of SAS are you most interested in?


A) BASE, STAT, GRAPH, ETSBriefly

Describe 5 ways to do a "table lookup" in SAS.


A) Match Merging, Direct Access, Format Tables, Arrays, PROC SQL

What versions of SAS have you used (on which platforms)?


A) SAS 9.1.3,9.0, 8.2 in Windows and UNIX, SAS 7 and 6.12

What are some good SAS programming practices for processing very large data sets?
A) Sampling method using OBS option or subsetting, commenting the Lines, Use Data Null

What are some problems you might encounter in processing missing values? In Data steps?
Arithmetic? Comparisons? Functions? Classifying data?
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.

How would you create a data set with 1 observation and 30 variables from a data set with 30
observations and 1 variable?
A) Using PROC TRANSPOSE

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

What are _numeric_ and _character_ and what do they do?


A) Will either read or writes all numeric and character variables in dataset.

How would you create multiple observations from a single observation?


A) Using double Trailing @@

For what purpose would you use the RETAIN statement?


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) (), **, *, /, +, -

How could you generate test data with no input data?


A) Using Data Null and put statement

How do you debug and test your SAS programs?


A) Using Obs=0 and systems options to trace the program execution in log.

What can you learn from the SAS log when debugging?
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.

What is the purpose of _error_?


A) It has only to values, which are 1 for error and 0 for no error.

How can you put a "trace" in your program?


A) By using ODS TRACE ON

How does SAS handle missing values in: assignment statements, functions, a merge, an update,
sort order, formats, PROCs?
A) Missing values will be assigned as missing in Assignment statement. Sort order treats missing as
second smallest followed by underscore.

How do you test for missing values?


A) Using Subset functions like IF then Else, Where and Select.

How are numeric and character missing values represented internally?


A) Character as Blank or “ and Numeric as.

Which date functions advances a date time or date/time value by a given interval?
A) INTNX.

In the flow of DATA step processing, what is the first action in a typical DATA Step?
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

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.
What are the scrubbing procedures in SAS?
A) Proc Sort with nodupkey option, because it will eliminate the duplicate values.

What are the new features included in the new version of SAS i.e., SAS9.1.3?
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.

WHAT DIFFERRENCE DID YOU FIND AMONG VERSION 6 8 AND 9 OF SAS.


The SAS 9
A) Architecture is fundamentally different from any prior version of SAS. In the SAS 9 architecture, SAS
relies on a new component, the Metadata Server, to provide an information layer between the programs
and the data they access. Metadata, such as security permissions for SAS libraries and where the various
SAS servers are running, are maintained in a common repository.

What has been your most common programming mistake?


A) Missing semicolon and not checking log after submitting program,
Not using debugging techniques and not using Fsview option vigorously.

Name several ways to achieve efficiency in your program.


Efficiency and performance strategies can be classified into 5 different areas.
·CPU time
·Data Storage
· Elapsed time
· Input/Output
· Memory CPU Time and Elapsed Time- Base line measurements

Few Examples for efficiency violations:


Retaining unwanted datasets Not sub setting early to eliminate unwanted records.
Efficiency improving techniques:
A)
Using KEEP and DROP statements to retain necessary variables. Use macros for reducing the code.
Using IF-THEN/ELSE statements to process data programming.
Use SQL procedure to reduce number of programming steps.
Using of length statements to reduce the variable size for reducing the Data storage.
Use of Data _NULL_ steps for processing null data sets for Data storage.

What other SAS products have you used and consider yourself proficient in using?
B) A) Data _NULL_ statement, Proc Means, Proc Report, Proc tabulate, Proc freq and Proc print, Proc
Univariate etc.

What is the significance of the 'OF' in X=SUM (OF a1-a4, a6, a9);
A) If don’t use the OF function it might not be interpreted as we expect. For example the function above
calculates the sum of a1 minus a4 plus a6 and a9 and not the whole sum of a1 to a4 & a6 and a9. It is
true for mean option also.

What do the PUT and INPUT functions do?


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.

Introduction to SAS Informats and Formats

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-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.

What do the MOD and INT function do? What do the PAD and DIM functions do? MOD:
A) Modulo is a constant or numeric variable, the function returns the reminder after numeric value divided
by modulo.

INT: It returns the integer portion of a numeric value truncating the decimal portion.

PAD: it pads each record with blanks so that all data lines have the same length. It is used in the INFILE
statement. It is useful only when missing data occurs at the end of the record.

CATX: concatenate character strings, removes leading and trailing blanks and inserts separators.
SCAN: it returns a specified word from a character value. Scan function assigns a length of 200 to each
target variable.

SUBSTR: extracts a sub string and replaces character values.Extraction of a substring:


Middleinitial=substr(middlename,1,1); Replacing character values: substr (phone,1,3)=’433’; If SUBSTR
function is on the left side of a statement, the function replaces the contents of the character variable.

TRIM: trims the trailing blanks from the character values.

SCAN vs. SUBSTR: SCAN extracts words within a value that is marked by delimiters. SUBSTR extracts a
portion of the value by stating the specific location. It is best used when we know the exact position of the
sub string to extract from a character value.

How might you use MOD and INT on numeric to mimic SUBSTR on character Strings?
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

In ARRAY processing, what does the DIM function do?


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.

How would you determine the number of missing or nonmissing values in computations?
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).

Do you need to know if there are any 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);

What is the difference between: x=a+b+c+d; and x=SUM (of a, b, c ,d);?


A) Is anyone wondering why you wouldn’t just use total=field1+field2+field3;

First, how do you want missing values handled?


The SUM function returns the sum of non-missing values. If you choose addition, you will get a missing
value for the result if any of the fields are missing. Which one is appropriate depends upon your
needs.However, there is an advantage to use the SUM function even if you want the results to be
missing. If you have more than a couple fields, you can often use shortcuts in writing the field names If
your fields are not numbered sequentially but are stored in the program data vector together then you can
use: total=SUM(of fielda--zfield); Just make sure you remember the “of” and the double dashes or your
code will run but you won’t get your intended results. Mean is another function where the function will
calculate differently than the writing out the formula if you have missing values.There is a field containing
a date. It needs to be displayed in the format "ddmonyy" if it's before 1975, "dd mon ccyy" if it's after
1985, and as 'Disco Years' if it's between 1975 and 1985.

How would you accomplish this in data step code?


Using only PROC FORMAT.

data new ;
input date ddmmyy10.;
cards;
01/05/1955
01/09/1970
01/12/1975
19/10/1979
25/10/1982
10/10/1988
27/12/1991
;
run;

proc format ;
value dat low-'01jan1975'd=ddmmyy10.'01jan1975'd-'01JAN1985'd="Disco Years"'
01JAN1985'd-high=date9.;
run;

proc print;
format date dat. ;
run;

In the following DATA step, what is needed for 'fraction' to print to the log?
data _null_;
x=1/3;
if x=.3333 then put 'fraction';
run;

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.

What are some differences between PROC SUMMARY and PROC MEANS?
Proc means by default give you the output in the output window and you can stop this by the option
NOPRINT and can take the output in the separate file by the statement OUTPUTOUT= , But, proc
summary doesn't give the default output, we have to explicitly give the output statement and then print the
data by giving PRINT option to see the result.

What is a problem with merging two data sets that have variables with the same name but
different data?
A) Understanding the basic algorithm of MERGE will help you understand how the stepProcesses. There
are still a few common scenarios whose results sometimes catch users off guard. Here are a few of the
most frequent 'gotchas':

1- BY variables has different lengthsIt is possible to perform a MERGE when the lengths of the BY
variables are different,But if the data set with the shorter version is listed first on the MERGE statement,
theShorter length will be used for the length of the BY variable during the merge. Due to this shorter
length, truncation occurs and unintended combinations could result.In Version 8, a warning is issued to
point out this data integrity risk. The warning will be issued regardless of which data set is listed
first:WARNING: Multiple lengths were specified for the BY variable name by input data sets.This may
cause unexpected results. Truncation can be avoided by naming the data set with the longest length for
the BY variable first on the MERGE statement, but the warning message is still issued. To prevent the
warning, ensure the BY variables have the same length prior to combining them in the MERGE step with
PROC CONTENTS. You can change the variable length with either a LENGTH statement in the merge
DATA step prior to the MERGE statement, or by recreating the data sets to have identical lengths for the
BY variables.Note: When doing MERGE we should not have MERGE and IF-THEN statement in one data
step if the IF-THEN statement involves two variables that come from two different merging data sets. If it
is not completely clear when MERGE and IF-THEN can be used in one data step and when it should not
be, then it is best to simply always separate them in different data step. By following the above
recommendation, it will ensure an error-free merge result.

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.

How do the IN= variables improve the capability of a MERGE?


A) The IN=variablesWhat if you want to keep in the output data set of a merge only the matches (only
those observations to which both input data sets contribute)? SAS will set up for you special temporary
variables, called the "IN=" variables, so that you can do this and more. Here's what you have to do: signal
to SAS on the MERGE statement that you need the IN= variables for the input data set(s) use the IN=
variables in the data step appropriately, So to keep only the matches in the match-merge above, ask for
the IN= variables and use them:data three;merge one(in=x) two(in=y); /* x & y are your choices of names
*/by id; /* for the IN= variables for data */if x=1 and y=1; /* sets one and two respectively */run;

What techniques and/or PROCs do you use for tables?


A) Proc Freq, Proc univariate, Proc Tabulate & Proc Report.

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 doesn’t produce n (%) in the desirable format.

How experienced are you with customized reporting and use of DATA _NULL_ features?
A) I have very good experience in creating customized reports as well as with Data _NULL_ step. It’s a
Data step that generates a report without creating the dataset there by development time can be saved.
The other advantages of Data NULL is when we submit, if there is any compilation error is there in the
statement which can be detected and written to the log there by error can be detected by checking the log
after submitting it. It is also used to create the macro variables in the data set.

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 difference between compiler and interpreter?


Give any one example (software product) that act as an interpreter?
A) Both are similar as they achieve similar purposes, but inherently different as to how they achieve that
purpose. The interpreter translates instructions one at a time, and then executes those instructions
immediately. Compiled code takes programs (source) written in SAS programming language, and then
ultimately translates it into object code or machine language. Compiled code does the work much more
efficiently, because it produces a complete machine language program, which can then be executed.

Code the table’s statement for a single level frequency?


A) Proc freq data=lib.dataset;
table var;*here you can mention single variable of multiple variables seperated by space to get single
frequency;
run;

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 other SAS features do you use for error trapping and data validation?
What are the validation tools in SAS?
A) For dataset: Data set name/debugData set: name/stmtchk
For macros: Options:mprint mlogic symbolgen.

How can you put a "trace" in your program?


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;

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.

Have you ever-linked SAS code, If so, describe the link and any required statements used to either
process the code or the step itself?

A) In the editor window we write%include 'path of the sas file';run;if it is with non-windowing
environment no need to give run statement.

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.

What is the difference between nodup and nodupkey options?


A) http://studysas.blogspot.com/2009/03/proc-sort-nodup-vs-nodupkey.html

1. Have you used macros? For what purpose you have used?
Yes I have, I used macros in creating analysis datasets and tables where it is necessary to make a small
change through out the program and where it is necessary to use the code again and again.

2. How would you invoke a macro?


After I have defined a macro I can invoke it by adding the percent sign prefix to its name like this: %
macro name a semicolon is not required when invoking a macro, though adding one generally does no
harm.
3. How can you create a macro variable with in data step?
with CALL SYMPUT

4. How would you identify a macro variable?


with Ampersand (&) sign

5. How would you define the end of a macro?


The end of the macro is defined by %Mend Statement

6. For what purposes have you used SAS macros?


If we want use a program step for executing to execute the same Proc step on multiple data sets. We can
accomplish repetitive tasks quickly and efficiently. A macro program can be reused many times.
Parameters passed to the macro program customize the results without having to change the code within
the macro program. Macros in SAS make a small change in the program and have SAS echo that change
thought that program.

7. What is the difference between %LOCAL and %GLOBAL?


% Local is a macro variable defined inside a macro.%Global is a macro variable defined in open code
(outside the macro or can use anywhere).

8. How long can a macro variable be? A token?


A component of SAS known as the word scanner breaks the program text into fundamental units called
tokens.
· Tokens are passed on demand to the compiler.
· The compiler then requests token until it receives a semicolon.
· Then the compiler performs the syntax check on the statement.

9. If you use a SYMPUT in a DATA step, when and where can you use the macro variable?
The macro variable created by the CALL SYMPUT routine cannot be used in the same datastep in which
it got created. Other than that we can use the macro variable at any time..

10. What do you code to create a macro? End one?


We create a macro with %MACRO statement and end a macro with %MEND statemnt.

11. What is the difference between %PUT and SYMBOLGEN?


%PUT is used to display user defined messages on log window after execution of a program where as %
SYMBOLGEN is used to print the value of a macro variable resolved, in log window.
12. How do you add a number to a macro variable?
Using %eval function or %sysevalf function if the number is a floating number.

13. Can you execute a macro within a macro? Describe.


Yes, Such macros are called nested macros. They can be obtained by using symget and call symput
macros.

14. If you need the value of a variable rather than the variable itself what would you use to load the
value to a macro variable?
If we need a value of a macro variable then we must define it in such terms so that we can call them
everywhere in the program. Define it as Global. There are different ways of assigning a global variable.
Simplest method is %LET.

Ex:
A, is macro variable. Use following statement to assign the value of a rather than the variable itself
%Let A=xyz; %put x="&A";

This will assign "xyz" to x, not the variable xyz to x.

15. Can you execute macro within another macro? If so, how would SAS know where the current
macro ended and the new one began?

Yes, I can execute macro within a macro, we call it as nesting of macros, which is allowed.
Every macro's beginning is identified the keyword %macro and end with %mend.

16. How are parameters passed to a macro?


A macro variable defined in parentheses in a %MACRO statement is a macro parameter. Macro
parameters allow you to pass information into a macro.

Here is a simple example:

%macro plot(yvar= ,xvar= );


proc plot;
plot &yvar*&xvar;
run;
%mend plot;
%plot(age,sex)

17. How would you code a macro statement to produce information on the SAS log?
This statement can be coded anywhere?
OPTIONS MPRINT MLOGIC MERROR SYMBOLGEN;

18. How we can call macros with in data step?


We can call the macro with
CALL SYMPUT,
Proc SQL ,
%LET statement. and macro parameters.

19. Tell me about call symput?

CALL SYMPUT takes a value from a data step and assigns it to a macro variable. I can then use this
macro variable in later steps. To assign a value to a single macro variable,

I use CALL SYMPUT with this general form:


CALL SYMPUT (“macro-variable-name”, value);
Where macro-variable-name, enclosed in quotation marks, is the name of a macro variable, and value is
the value I want to assign to that macro variable. Value can be the name of a variable whose value SAS
will use, or it can be a constant value enclosed quotation marks.

more abt callsymput routine can be read at:


http://studysas.blogspot.com/2009/08/call-symput-vs-call-symputx.html

CALL SYMPUT is often used in if-then statements such as this:


If age>=18 then call symput (“status”,”adult”);
else call symput (“status”,”minor”);

These statements create a macro variable named &status and assign to it a value of either adult or minor
depending on the variable age.Caution: We cannot create a macro variable with CALL SYMPUT and use
it in the same data step because SAS does not assign a value to the macro variable until the data step
executes. Data steps executes when SAS encounters a step boundary such as a subsequent data, proc,
or run statement.

20. Tell me about % include and % eval?


The %include statement, despite its percent sign, is not a macro statement and is always executed in
SAS, though it can be conditionally executed in a macro.It can be used to setting up a macro library. But
this is a least approach.

The use of %include does not actually set up a library. The %include statement points to a file and when it
executed the indicated file (be it a full program, macro definition, or a statement fragment) is inserted into
the calling program at the location of the call.

When using the %include building a macro library, the included file will usually contain one or more macro
definitions.%EVAL is a widely used yet frequently misunderstood SAS(r) macro language function due to
its seemingly simple form.

However, when its actual argument is a complex macro expression interlaced with special characters,
mixed arithmetic and logical operators, or macro quotation functions, its usage and result become elusive
and problematic. %IF condition in macro is evaluated by %eval, to reduce it to true or false.

21. Describe the ways in which you can create macro variables?
There are the 5 ways to create macro variables:
%Let
%Global
Call Symput
Proc SQl into clause
Macro Parameters.

22. Tell me more about the parameters in macro?


Parameters are macro variables whose value you set when you invoke a macro. To add the parameters
to a macro, you simply name the macro vars names in parenthesis in the %macro statement.
Syntax:
%MACRO macro-name (parameter-1= , parameter-2= , ……parameter-n = );
macro-text%;
%MEND macro-name;
%macro_name(par1,par2,....parn);

23. What is the maximum length of the macro variable?


32 characters long.

24. Automatic variables for macro?


Every time we invoke SAS, the macro processor automatically creates certain macro var. eg: &sysdate
&sysday.

25. What system options would you use to help debug a macro?
The SAS System offers users a number of useful system options to help debug macro issues and
problems. The results associated with using macro options are automatically displayed on the SAS Log.

Specific options related to macro debugging appear in alphabetical order in the table below:

MEMRPT: Specifies that memory usage statistics be displayed on the SAS Log.
MERROR: SAS will issue warning if we invoke a macro that SAS didn’t find. Presents Warning Messages
when there are misspellings or when an undefined macro is called.
SERROR: SAS will issue warning if we use a macro variable that SAS can’t find.
MLOGIC: SAS prints details about the execution of the macros in the log.
MPRINT: Displays SAS statements generated by macro execution are traced on the SAS Log for
debugging purposes.
SYMBOLGEN: SAS prints the value of macro variables in log and also displays text from expanding
macro variables to the SAS Log.

27. What are SYMGET and SYMPUT?


SYMPUT puts the value from a dataset into a macro variable where as
SYMGET gets the value from the macro variable to the dataset.

28. What are the macros you have used in your programs?
Used macros for various puposes, few of them are..

1) Macros written to determine the list of variables in a dataset:


%macro varlist (dsn);
proc contents data = &dsn out = cont noprint;
run;
%mend;
%varlist(demo);

proc sql noprint;


select distinct name into:varname1-:varname22 from cont;
quit;

%do i =1 %to &sqlobs;


%put &i &&varname&i;
%end;
%mend varlist;
%varlist(adverse)

2) Distribution or Missing / Non-Missing Values


%macro missrep (dsn, vars=_numeric_);

proc freq data=&dsn.;


tables &vars. / missing;
format _character_ $missf. _numeric_ missf.;
title1 ‘Distribution or Missing / Non-Missing Values’;
run;
%mend missrep;
%missrep(study.demog, vars=age gender bdate);

3) Written macros for sorting common variables in various datasets


%macro sortit (datasetname,pid,inverstigator);

PROC SORT DATA = &DATASETNAME;


BY &PID &INVESTIGATOR;
%mend sortit;
%sortit (ae,001,sarath);

4) Macros written to split the number of observations in a dataset

%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)

29. What is auto call macro and how to create a auto call macro? What is the use of it? How to use
it in SAS with macros?

SAS Enables the user to call macros that have been stored as SAS programs.

The auto call macro facility allows users to access the same macro code from multiple SAS programs.
Rather than having the same macro code for in each program where the code is required, with an autocall
macro, the code is in one location. This permits faster updates and better consistency across all the
programs.Macro set-up:The fist step is to set-up a program that contains a macro, desired to be used in
multiple programs. Although the program may contain other macros and/or open code, it is advised to
include only one macro.

Set MAUTOSOURSE and SASAUTOS:


Before one can use the autocall macro within a SAS program, The MAUTOSOURSE option must be set
open and the SASAUTOS option should be assigned. The MAUTOSOURSE option indicates to SAS that
the autocall facility is to be activated. The SASAUTOS option tells SAS where to look for the macros.

For ex: sasauto=’g:\busmeas\internal\macro\’;

30. Why and How to Use %PUT Statement:

%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 can’t
with PUT.

How to use %PUT:

%let program=AE;
%put program Name here as &program;

Above %put statement resolves to … %put Program Name here as AE;

What can you do with %PUT:

Numerous options are available for the %PUT statement.

%PUT _all_:
It prints all macro variables in the log that are available in all environments (global, local, user and
automatic).

%PUT _automatic_:
It prints all the SAS defined automatic macro variables in the log. (ex: &sysdate, &systime ,%sysdsn,
%syserr etc)

%PUT _global_:
It prints macro variables that are created by the user and available in all environments.

%PUT _local_:
It prints macro variables that are created by the user and available only in the local environment. (couldn’t
be able use those macro variables outside the particular data step)

%PUT _user_:
It prints macro variables that are created by the user in each environment.
31) How to know how &&var&i or &&dsn&i resolves?
It is very confusing some times to tell rightaway how &&var&i or &&dsn&i get resolved...
but here is the simple technique you can use to know....
ex: We generally use &&var&i or &&dsn&i these macro variables when we are using a %do loop... to
execute same code n number of times.
You have a dataset and it has 5 variables ... Patid sex age ethnic race wt ht;
%macro doit;
%do i=1 %to &nvars;
&&var&i
%end;
%mend doit;
So if the nvars value is 7, then the loop creates a macro variable list of
&var1 &var2 &var3 &var4 &var5 &var6 &var7
which further get resolved to
patid sex age ethnic race wt ht
You can always use Macro debugging option SYMBOLGEN to see how each macro variable got
resolved....

Question: What is the function of output statement?

Answer: To override the default way in which the DATA step writes observations to output, you can use an
OUTPUT statement in the DATA step. Placing an explicit OUTPUT statement in a DATA step overrides the
automatic output, so that observations are added to a data set only when the explicit OUTPUT statement is
executed.

Question: What is the function of Stop statement?

Answer: Stop statement causes SAS to stop processing the current data step immediately and resume processing
statement after the end of current data step.

Question : What is the difference between using drop= data set option in data statement and set statement?

Answer: If you don’t want to process certain variables and you do not want them to appear in the new data set, then
specify drop= data set option in the set statement.

Whereas If want to process certain variables and do not want them to appear in the new data set, then specify
drop= data set option in the data statement.

Question: Given an unsorted dataset, how to read the last observation to a new data set?

Answer: using end= data set option.

For example:

data work.calculus;

set work.comp end=last;

If last;

run;

Where Calculus is a new data set to be created and Comp is the existing data set

last is the temporary variable (initialized to 0) which is set to 1 when the set statement reads the last observation.

Question : What is the difference between reading the data from external file and reading the data from
existing data set?

Answer: The main difference is that while reading an existing data set with the SET statement, SAS retains the
values of the variables from one observation to the next.

Question: What is the difference between SAS function and procedures?

Answer: Functions expects argument value to be supplied across an observation in a SAS data set and procedure
expects one variable value per observation.
 For example:

data average ;

set temp ;

avgtemp = mean( of T1 – T24 ) ;

run ;

Here arguments of mean function are taken across an observation.

 proc sort ;

by month ;

run ;

 proc means ;

by month ;

var avgtemp ;

run ;

Proc means is used to calculate average temperature by month (taking one variable value across an observation).

Question: Differnce b/w sum function and using “+” operator?

Answer: SUM function returns the sum of non-missing arguments whereas “+” operator returns a missing value if
any of the arguments are missing.

Example:
data mydata;
input x y z;
cards;
33 3 3
24 3 4
24 3 4
.32
23 . 3
54 4 .
35 4 2
;
run;

data mydata2;
set mydata;
a=sum(x,y,z);
p=x+y+z;
run;
In the output, value of p is missing for 3rd, 4th and 5th observation as :

ap
39 39
31 31
31 31
5.
26 .
58 .
41 41

Question: What would be the result if all the arguments in SUM function are missing?

Answer: a missing value

Question: What would be the denominator value used by the mean function if two out of seven arguments are
missing?

Answer: five

Question: Give an example where SAS fails to convert character value to numeric value automatically?

Answer: Suppose value of a variable PayRate begins with a dollar sign ($). When SAS tries to automatically convert
the values of PayRate to numeric values, the dollar sign blocks the process. The values cannot be converted to
numeric values.

Therefore, it is always best to include INPUT and PUT functions in your programs when conversions occur.

Question: What would be the resulting numeric value (generated by automatic char to numeric conversion) of a
below mentioned character value when used in arithmetic calculation?

1,735.00

Answer: a missing value

Question: What would be the resulting numeric value (generated by automatic char to numeric conversion) of a
below mentioned character value when used in arithmetic calculation?

1735.00

Answer: 1735
 

Question: Which SAS statement does not perform automatic conversions in comparisons?

Answer: where statement

Question: Briefly explain Input and Put function?

Answer:  Input function – Character to numeric conversion- Input(source,informat)

                put function –  Numeric to character conversion- put(source,format)

Question: What would be the result of following SAS function(given that 31 Dec, 2000 is Sunday)?

Weeks = intck (‘week’,’31 dec 2000′d,’01jan2001′d);

Years = intck (‘year’,’31 dec 2000′d,’01jan2001′d);

Months = intck (‘month’,’31 dec 2000′d,’01jan2001′d);

Answer: Weeks=0, Years=1,Months=1

Question: What are the parameters of Scan function?

Answer: scan(argument,n,delimiters)

argument specifies the character variable or expression to scan

n specifies which word to read

delimiters are special characters that must be enclosed in single quotation marks

Question: Suppose the variable address stores the following expression:

209 RADCLIFFE ROAD, CENTER CITY, NY, 92716

What would be the result returned by the scan function in the following cases?

a=scan(address,3);

b=scan(address,3,’,');

Answer: a=Road; b=NY

Question: What is the length assigned to the target variable by the scan function?
Answer: 200

Question: Name few SAS functions?

Answer: Scan, Substr, trim, Catx, Index, tranwrd, find, Sum.

Question: What is the function of tranwrd function?

Answer: TRANWRD function replaces or removes all occurrences of a pattern of characters within a

character string.

Question: Consider the following SAS Program

data finance.earnings;

Amount=1000;

Rate=.075/12;

do month=1 to 12;

Earned+(amount+earned)*(rate);

end;

run;

What would be the value of month at the end of data step execution and how many observations would be there?

Answer: Value of month would be 13

               No. of observations would be 1

Question: Consider the following SAS Program

data finance;

Amount=1000;

Rate=.075/12;

do month=1 to 12;

Earned+(amount+earned)*(rate);
output;

end;

run;

How many observations would be there at the end of data step execution?

Answer: 12

Question: How do you use the do loop if you don’t know how many times should you execute the do loop?

Answer: we can use do until or do while to specify the condition.

Question: What is the difference between do while and do until?

Answer: An important difference between the DO UNTIL and DO WHILE statements is that the DO WHILE
expression is evaluated at the top of the DO loop. If the expression is false the first time it is evaluated, then the DO
loop never executes. Whereas DO UNTIL  executes at least once.

Question: How do you specify number of iterations and specific condition within a single do loop?

Answer:

data work;

do i=1 to 20 until(Sum>=20000);

Year+1;

Sum+2000;

Sum+Sum*.10;

end;

run;

This iterative DO statement enables you to execute the DO loop until Sum is greater than or equal to 20000 or until
the DO loop executes 10 times, whichever occurs first.

Question: How many data types are there in SAS?

Answer: Character, Numeric


 

Question: If a variable contains only numbers, can it be character data type? Also give example

Answer: Yes, it depends on how you use the variable

               Example: ID, Zip are numeric digits and can be character data type.

Question: If a variable contains letters or special characters, can it be numeric data type?

Answer: No, it must be character data type.

Question; What can be the size of largest dataset in SAS?

Answer: The number of observations is limited only by computer’s capacity to handle and store them.

Prior to SAS 9.1, SAS data sets could contain up to 32,767 variables. In SAS 9.1, the maximum number of variables
in a SAS data set is limited by the resources available on your computer.

Question: Give some example where PROC REPORT’s defaults are different than PROC PRINT’s defaults?

Answer:

 No Record Numbers in Proc Report


 Labels (not var names) used as headers in Proc Report
 REPORT needs NOWINDOWS option
 

Question: Give some example where PROC REPORT’s defaults are same as PROC PRINT’s defaults?

Answer:

 Variables/Columns in position order.


 Rows ordered as they appear in data set.
 

Question: Highlight the major difference between below two programs:

 a.

 data mydat;

input ID Age;

cards;
2 23

4 45

3 56

9 43

run;

proc report data = mydat nowd;

column ID Age;

run;

b.

data mydat1;

input grade $ ID Age;

cards;

A 2 23

B 4 45

C 3 56

D 9 43

run;

proc report data = mydat1 nowd;

column Grade ID Age;

run;

Answer: When all the variables in the input file are numeric, PROC REPORT does a sum as a default.Thus first
program generates one record in the list report whereas second generates four records.

Question: In the above program, how will you avoid having the sum of numeric variables?

Answer: To avoid having the sum of numeric variables, one or  more of the input variables must be defined as
DISPLAY.
Thus we have to use :

proc report data = mydat nowd;

column ID Age;

define ID/display;

run;

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: How to limit decimal places for variable using PROC MEANS?

Answer: By using MAXDEC= option

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.
 

Question: What is the difference between PROC MEANS and PROC Summary?
Answer: The difference between the two procedures is that PROC MEANS produces a report by default. By contrast,
to produce a report in PROC SUMMARY, you must include a PRINT option in the PROC SUMMARY statement.

Question: How to specify variables to be processed by the FREQ procedure?

Answer: By using TABLES Statement.

Question: Describe CROSSLIST option in  TABLES statement?

Answer: Adding the CROSSLIST option to TABLES statement displays crosstabulation tables in ODS column format.

Question: How to create list output for crosstabulations in proc freq?

Answer: To generate list output for crosstabulations, add a slash (/) and the LIST option to the TABLES statement
in your PROC FREQ step.

TABLES variable-1*variable-2 <* … variable-n> / LIST;

Question: Proc Means work for ________ variable and Proc FREQ Work for ______ variable?

Answer: Numeric, Categorical

Question: How can you combine two datasets based on the relative position of rows in each data set; that is, the
first observation in one data set is joined with the first observation in the other, and so on?

Answer: One to One reading

Question: data concat;

        set a b;

        run;

format of variable Revenue in dataset a is dollar10.2 and format  of variable Revenue in dataset b is dollar12.2  

What would be the format of Revenue in resulting dataset (concat)?

Answer: dollar10.2

 
Question: If you have two datasets you want to combine them in the manner such that observations in each BY
group in each data set in the SET statement are read sequentially, in the order in which the data sets and BY
variables are listed then which method of combining datasets will work for this?

Answer: Interleaving

Question: While match merging two data sets, you cannot use the __________option with indexed data sets
because indexes are always stored in ascending order.

Answer: Descending

Question: I have a dataset concat having variable a b & c. How to rename a b to e & f?

Answer:  data concat(rename=(a=e b=f));

                set concat;

                run;

 Question : What is the difference between One to One Merge and Match Merge? Give example also..

Answer: If both data sets in the merge  statement are sorted by id(as shown below) and each observation in one
data set has a corresponding observation in the other data set, a one-to-one merge is suitable.

data mydata1;

input id class $;

cards;

1 Sa

2 Sd

3 Rd

4 Uj

data mydata2;

input id class1 $;

cards;

1 Sac
2 Sdf

3 Rdd

4 Lks

data mymerge;

merge mydata1 mydata2;

run;

If the observations do not match, then match merging is suitable

data mydata1;

input id class $;

cards;

1 Sa

2 Sd

2 Sp

3 Rd

4 Uj

data mydata2;

input id class1 $;

cards;

1 Sac

2 Sdf

3 Rdd

3 Lks

5 Ujf

data mymerge;
merge mydata1 mydata2;

by id

run;

You might also like