Sample Answer 2
Sample Answer 2
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 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.
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 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.
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.
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.
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.
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
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.
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.
You know that your key strategy is to first uncover your interviewer's greatest wants and needs
before you answer questions.
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:
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.
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 ?
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.
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.
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?
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.
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 ........
Other questions:
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 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.
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.
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 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 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 ·
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.
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)
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.
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
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).
You can also find the number of non-missing values with non_missing=N (field1,field2,field3);
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 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 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 would you code a merge that will keep only the observations that have matches from both
data sets?
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;
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.
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.
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..
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";
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.
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;
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,
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.
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.
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.
28. What are the macros you have used in your programs?
Used macros for various puposes, few of them are..
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.
%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.
%let program=AE;
%put program Name here as &program;
%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....
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.
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?
For example:
data work.calculus;
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.
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 ;
run ;
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).
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?
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
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?
Question: What would be the result of following SAS function(given that 31 Dec, 2000 is Sunday)?
Answer: scan(argument,n,delimiters)
delimiters are special characters that must be enclosed in single quotation marks
What would be the result returned by the scan function in the following cases?
a=scan(address,3);
b=scan(address,3,’,');
Question: What is the length assigned to the target variable by the scan function?
Answer: 200
Answer: TRANWRD function replaces or removes all occurrences of a pattern of characters within a
character string.
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?
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: 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: If a variable contains only numbers, can it be character data type? Also give example
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: 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:
Question: Give some example where PROC REPORT’s defaults are same as PROC PRINT’s defaults?
Answer:
a.
data mydat;
input ID Age;
cards;
2 23
4 45
3 56
9 43
run;
column ID Age;
run;
b.
data mydat1;
cards;
A 2 23
B 4 45
C 3 56
D 9 43
run;
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 :
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.
Question: How to limit decimal places for variable using PROC MEANS?
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.
Answer: Adding the CROSSLIST option to TABLES statement displays crosstabulation tables in ODS column format.
Answer: To generate list output for crosstabulations, add a slash (/) and the LIST option to the TABLES statement
in your PROC FREQ step.
Question: Proc Means work for ________ variable and Proc FREQ Work for ______ variable?
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?
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
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?
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;
run;
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;