This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Does Sas Handle Missing Values In: Assignment Statements, Functions, A Merge, An Update, Sort Order, Formats, Procs? |
|
Answer» When you check for ordinary missing numeric VALUES, you can USE code that is similar to the following: if numvar=. then do; If your DATA contains SPECIAL missing values, you can check for either an ordinary or special missing value with a STATEMENT that is similar to the following: if numvar<=.z then do; To check for a missing character value, you can use a statement that is similar to the following: if charvar=' ' then do; The MISSING function enables you to check for either a character or numeric missing value, as in: if missing(var) then do; When you check for ordinary missing numeric values, you can use code that is similar to the following: if numvar=. then do; If your data contains special missing values, you can check for either an ordinary or special missing value with a statement that is similar to the following: if numvar<=.z then do; To check for a missing character value, you can use a statement that is similar to the following: if charvar=' ' then do; The MISSING function enables you to check for either a character or numeric missing value, as in: if missing(var) then do; |
|
| 2. |
Why Is Sas Considered Self-documenting? |
|
Answer» When DATA SET is created sas CREATE descriptor portion and data portion .that means sas STORES the information like variable name ,length,type etc. When data set is created sas create descriptor portion and data portion .that means sas stores the information like variable name ,length,type etc. |
|
| 3. |
What Are Some Good Sas Programming Practices For Processing Very Large Data Sets? |
|
Answer» ARRAYS is USED for processing for large DATA SET. Arrays is used for processing for large data set. |
|
| 4. |
How Would You Create Multiple Observations From A Single Observation? |
|
Answer» LINE POINTER is used for multiple lines per OBSERVATION @@ is used for multiple observations per line line pointer is used for multiple lines per observation @@ is used for multiple observations per line |
|
| 5. |
How Do You Test For Missing Values? |
|
Answer» NMISS OPTION is USED for MISSING VALUES. NMISS OPTION is used for missing values. |
|
| 6. |
What Is The Significance Of The ‘of’ In X=sum (of A1-a4, A6, A9);? |
|
Answer» It is use to tell sas to consider a SET of values to be processed. In the above example, SUM(OF A1-A4,a6,a9) RESOLVES to SUM(A1,A2,A3,A4,A6,A9). If we dont use 'OF' then it would be treated as a minus sign.. A1(Minus)-A4 and that is not what we are trying to ACCOMPLISH. It is use to tell sas to consider a set of values to be processed. In the above example, SUM(OF a1-a4,a6,a9) resolves to SUM(A1,A2,A3,A4,A6,A9). If we dont use 'OF' then it would be treated as a minus sign.. A1(Minus)-A4 and that is not what we are trying to accomplish. |
|
| 7. |
What Is The Purpose Of The Trailing And How Would You Use Them? |
|
Answer» If the data is continuosly in data SET SAS would read the first WORDS only from each line in the `datelines' block and it will ignore the rest of the line. if we use Trailing @@'it will read completly.and another TYPE of trailing is using single @ this is a line hold SPECIFIER.
They are used for the records such as 001F38 H 002 F 40 G To read these values to the data step Data example: input @10 type $ @; if type='H' then input @1 id 3. @4 GENDER $1. @5 age2.; else if type='G' then input @1 id3. @5 gender $1. @7 age 2.; end; cards; 001F38 H 002 F 40 G ; run; The double trailing holds the until the end of the record. Data example2: input id age @@; cards; 001 23 002 43 003 65 004 32 005 54 ; run; If the data is continuosly in data set SAS would read the first words only from each line in the `datelines' block and it will ignore the rest of the line. if we use Trailing @@'it will read completly.and another type of trailing is using single @ this is a line hold specifier. They are used for the records such as 001F38 H 002 F 40 G To read these values to the data step Data example: input @10 type $ @; if type='H' then input @1 id 3. @4 gender $1. @5 age2.; else if type='G' then input @1 id3. @5 gender $1. @7 age 2.; end; cards; 001F38 H 002 F 40 G ; run; The double trailing holds the until the end of the record. Data example2: input id age @@; cards; 001 23 002 43 003 65 004 32 005 54 ; run; |
|
| 8. |
If You Have A Data Set That Contains 100 Variables, But You Need Only Five Of Those, What Is The Code To Force Sas To Use Only That Variable? |
|
Answer» Use KEEP option on a dataset to only select few variables from 100 variables. We can use KEEP option either on set statement or data step statement. If we use on SET statement then only the five variables are created on PDV and only these variables are sent to the OUTPUT dataset. If we use KEEP option on data step statement then all the variables are copied into pdv and after any manipulation only the selected variables on data step statement are PROCESSED and sent to output dataset. data abc; set xyz (keep= ab cd ef GH); run; data abc(keep= ab cd ef gh IJ); set xyz; ij=ab+jk; run; Use KEEP option on a dataset to only select few variables from 100 variables. We can use KEEP option either on set statement or data step statement. If we use on SET statement then only the five variables are created on pdv and only these variables are sent to the output dataset. If we use KEEP option on data step statement then all the variables are copied into pdv and after any manipulation only the selected variables on data step statement are processed and sent to output dataset. data abc; set xyz (keep= ab cd ef gh); run; data abc(keep= ab cd ef gh ij); set xyz; ij=ab+jk; run; |
|
| 9. |
When Looking For Data Contained In A Character String Of 150 Bytes, Which Function Is The Best To Locate That Data: Scan, Index, Or Index C? |
|
Answer» INDEX: Searches a character expression for a string of CHARACTERS, and returns the position of the string's first character for the first OCCURRENCE of the string. INDEX (source, excerpt) it returns the position where the 2nd field is in the source Eg: str1 = 'Hi i am fine here. how are u there ? .....'; str2 = index(str1,'how'); --> str2 = 20 SCAN is to get a substring upto MENTIONED character. Scan function the best for locating the particular word specified in a ARGUMENT,scan function default length is 200bytes. data k; r='ganesh kumar'; u=scan(r,2); proc print; run; result: kumar INDEXC to locate only for mentioned one or more single character INDEXC(character-value, 'char1','char2','char3', ..) FIND: Searches for a specific substring of characters within a character string FIND(string, substring<,modifiers><,startups>) it returns the position the substring is in FINDC: To locate a character that appears or does not appear within a string. used to search for any one in a list of character values INDEXW: Searches for the substring as a word that follows a space in the provided sentence eg;string1= "there is a the here" ; INDEXW(STRING1,"the") result: 12 (the word "the") INDEX: Searches a character expression for a string of characters, and returns the position of the string's first character for the first occurrence of the string. INDEX (source, excerpt) it returns the position where the 2nd field is in the source Eg: str1 = 'Hi i am fine here. how are u there ? .....'; str2 = index(str1,'how'); --> str2 = 20 SCAN is to get a substring upto mentioned character. Scan function the best for locating the particular word specified in a argument,scan function default length is 200bytes. data k; r='ganesh kumar'; u=scan(r,2); proc print; run; result: kumar INDEXC to locate only for mentioned one or more single character INDEXC(character-value, 'char1','char2','char3', ..) FIND: Searches for a specific substring of characters within a character string FIND(string, substring<,modifiers><,startups>) it returns the position the substring is in FINDC: To locate a character that appears or does not appear within a string. used to search for any one in a list of character values INDEXW: Searches for the substring as a word that follows a space in the provided sentence eg;string1= "there is a the here" ; INDEXW(STRING1,"the") result: 12 (the word "the") |
|
| 10. |
Name And Describe Three Sas Functions That You Have Used, If Any? |
Answer»
different types of functions:
TRIM : REMOVING the trailing blanks from character expressions. syntax=trim(argument) SUBSTR: substr extracts the substring from an argument syntax=substr(argument, position<,n>) Abs: Returns the absolute of the argument Syntax=abs(argument) The most common functions that would be used are- Conversion functions - Input / Put / int / ceil / floor Character functions - Scan / substr / index / Left / trim / compress / cat / catx / upcase,lowcase Arithmetic functions - Sum / abs / Attribute info functions – Attrn / length Dataset – OPEN / close / exist Directory - dexist / DOPEN / dclose / dcreate / dinfo File functions – fexist / fopen/ filename / fileref SQL functions – coalesce / count / sum/ mean Date functions – date / today / datdif / datepart / DATETIME / intck / mdy Array functions – dim different types of functions: TRIM : Removing the trailing blanks from character expressions. syntax=trim(argument) SUBSTR: substr extracts the substring from an argument syntax=substr(argument, position<,n>) Abs: Returns the absolute of the argument Syntax=abs(argument) The most common functions that would be used are- Conversion functions - Input / Put / int / ceil / floor Character functions - Scan / substr / index / Left / trim / compress / cat / catx / upcase,lowcase Arithmetic functions - Sum / abs / Attribute info functions – Attrn / length Dataset – open / close / exist Directory - dexist / dopen / dclose / dcreate / dinfo File functions – fexist / fopen/ filename / fileref SQL functions – coalesce / count / sum/ mean Date functions – date / today / datdif / datepart / datetime / intck / mdy Array functions – dim |
|
| 11. |
How Do U Validate Sas Program? |
|
Answer» When a sas code is submitted, SAS PERFORMS syntactical checks before executing the program/ code. In that case, one of the ways COULD be - at the beginning of the code, write OPTIONS OBS=0 in addition to other options and then RUN it. This way DATA will not be PROCESSED and the log shows error messages/ warnings, if any. If you are executing the SAS code on PC SAS, the highlighted colors itself shows the syntactical ERRORS, if any. When a sas code is submitted, SAS performs syntactical checks before executing the program/ code. In that case, one of the ways could be - at the beginning of the code, write OPTIONS OBS=0 in addition to other options and then RUN it. This way data will not be processed and the log shows error messages/ warnings, if any. If you are executing the SAS code on PC SAS, the highlighted colors itself shows the syntactical errors, if any. |
|
| 12. |
At Compile Time When A Sas Data Set Is Read, What Items Are Created? |
|
Answer» Only PDV is GENERATED at compilation TIME, whereas the automatic variables _N_ , _ERROR_ are generated at EXECUTION time only. Only PDV is generated at compilation time, whereas the automatic variables _N_ , _ERROR_ are generated at execution time only. |
|
| 13. |
Does Sas ?translate? (compile) Or Does It ?interpret? |
|
Answer» A typical SAS program could contain DATA steps, PROC steps and macros. Macros are PREPROCESSED. DATA steps are just in time compiled. PROC steps are interpreted in the ORDER they appear in program. So when we submit a SAS program consisting of all these three components, the macro is compiled and executed first. If a DATA step is encountered, then it is compiled and executed. NOTE that the DATA step will not be executed if there is an error in the compilation. If a PROC step is encountered, it is interpreted and executed LINE by line. However i am not certain on this PROC step behavior. A typical SAS program could contain DATA steps, PROC steps and macros. Macros are preprocessed. DATA steps are just in time compiled. PROC steps are interpreted in the order they appear in program. So when we submit a SAS program consisting of all these three components, the macro is compiled and executed first. If a DATA step is encountered, then it is compiled and executed. Note that the DATA step will not be executed if there is an error in the compilation. If a PROC step is encountered, it is interpreted and executed line by line. However i am not certain on this PROC step behavior. |
|
| 14. |
In The Flow Of Data Step Processing, What Is The First Action In A Typical Data Step? |
|
Answer» 1)COMPILATION Phase: When you submit a DATA step, it reads the input statements it creates an input buffer and brings the variables and observations. it is a logical MEMORY area and pdv brings the observations at a time from input buffer and checks the errors. PDV contains 2 automatic variables _n_ & _error_, these checks the errors in observations. _n_: indicates the no of OBS. _error_: 1 if ERROR occured 0 if no error After that it assigns the data values to appropriate variable and builds a sas dataset. 1)Compilation Phase: When you submit a DATA step, it reads the input statements it creates an input buffer and brings the variables and observations. it is a logical memory area and pdv brings the observations at a time from input buffer and checks the errors. PDV contains 2 automatic variables _n_ & _error_, these checks the errors in observations. _n_: indicates the no of obs. _error_: 1 if error occured 0 if no error After that it assigns the data values to appropriate variable and builds a sas dataset. |
|
| 15. |
How To Display Duplicate Observations In A Data Using Base Sas? |
|
Answer» There are two ways to DISPLAY DUPLICATE observations: There are two ways to display duplicate observations: |
|
| 16. |
How Would You Remove A Format That Has Been Permanently Associated With A Variable? |
|
Answer» we can remove the format by using proc datasets: Proc datasets; format <VARIABLE name>(which variable format needs to modify>; RUN; quit; we can remove the format by using proc datasets: Proc datasets; modify <data set name>; format <variable name>(which variable format needs to modify>; run; quit; |
|
| 17. |
How Will You Read An Input File Into Sas? |
|
Answer» Use the statements INFILE to point to the FILE reference(should be defined using FILENAME) / to the file path. Use INPUT STATEMENT to read the data into the SAS dataset. Use the statements INFILE to point to the file reference(should be defined using Filename) / to the file path. Use INPUT statement to read the data into the sas dataset. |
|
| 18. |
Do You Use Proc Report Or Proc Tabulate? Which Do You Prefer? |
|
Answer» I prefer PROC report as it is highly CUSTOMIZABLE and flexible where I can define each column in whatever way I want to and even make use of SAS functions, logic processing, and assignment statements and create new. Variables for report MAKING use of the compute block of proc report. I referred proc report because it is more EFFICIENT tool than tabulate because with report we can do means frequency and tabulate also. I prefer Proc report as it is highly customizable and flexible where I can define each column in whatever way I want to and even make use of SAS functions, logic processing, and assignment statements and create new. Variables for report making use of the compute block of proc report. I referred proc report because it is more efficient tool than tabulate because with report we can do means frequency and tabulate also. |
|
| 19. |
How Will You Write A Code To Create A Sas Data Set With No Data In It/ Or How To Validate A Data Set Without Actual Creating It? |
|
Answer» 1)Use OPTIONS OBS = 0 1)Use OPTIONS OBS = 0 |
|
| 20. |
Difference Between Proc Means & Proc Summary? |
Answer»
|
|
| 21. |
Why And When Do You Use Proc Sql? |
|
Answer» Proc SQL is very convenient for PERFORMING table joins compared to a data step merge as it does not REQUIRE the key columns to be sorted PRIOR to join. A data step is more suitable for sequential observation-by-observation processing. PROC SQL can SAVE a great deal of time if u want to filter the variables while selecting or we can modify them, apply format and CREATING new variables, macro variables. as well as subsetting the data. PROC SQL offers great flexibility for joining tables. Proc SQL is very convenient for performing table joins compared to a data step merge as it does not require the key columns to be sorted prior to join. A data step is more suitable for sequential observation-by-observation processing. PROC SQL can save a great deal of time if u want to filter the variables while selecting or we can modify them, apply format and creating new variables, macro variables. as well as subsetting the data. PROC SQL offers great flexibility for joining tables. |
|
| 22. |
How Do You Merge Data In Proc Sql? |
|
Answer» The three TYPES of join are inner join, left join and right join. The inner join option TAKES the matching values from both the tables by the ON option. The left join selects all the VARIABLES from the first table and JOINS second table to it. The right join selects all the variables of table b first and join the table a to it. PROC SQL; CREATE TABLE BOTH AS SELECT A.PATIENT, A.DATE FORMAT=DATE7. AS DATE, A.PULSE,B.MED, B.DOSES, B.AMT FORMAT=4.1 FROM VITALS A INNER JOIN DOSING B ON (A.PATIENT = B.PATIENT) AND(A.DATE = B.DATE) ORDER BY PATIENT, DATE; QUIT; The three types of join are inner join, left join and right join. The inner join option takes the matching values from both the tables by the ON option. The left join selects all the variables from the first table and joins second table to it. The right join selects all the variables of table b first and join the table a to it. PROC SQL; CREATE TABLE BOTH AS SELECT A.PATIENT, A.DATE FORMAT=DATE7. AS DATE, A.PULSE,B.MED, B.DOSES, B.AMT FORMAT=4.1 FROM VITALS A INNER JOIN DOSING B ON (A.PATIENT = B.PATIENT) AND(A.DATE = B.DATE) ORDER BY PATIENT, DATE; QUIT; |
|
| 23. |
Have U Ever Used Proc Sql To Read In A Raw Data File? |
|
Answer» No. I don’t THINK it can be USED. No. I don’t think it can be used. |
|
| 24. |
What Types Of Programming Tasks Do You Use Proc Sql For Versus The Data Step? |
|
Answer» Proc SQL is very convenient for performing table joins compared to a data step merge as it does not require the key columns to be sorted PRIOR to join. A data step is more suitable for sequential observation-by-observation processing.PROC SQL can save a GREAT deal of time if u want to filter the VARIABLES while selecting or u can modify them …apply format….creating new variables , macro variables…as well as SUB setting the data.PROC SQL offers great FLEXIBILITY for joining tables. Proc SQL is very convenient for performing table joins compared to a data step merge as it does not require the key columns to be sorted prior to join. A data step is more suitable for sequential observation-by-observation processing.PROC SQL can save a great deal of time if u want to filter the variables while selecting or u can modify them …apply format….creating new variables , macro variables…as well as sub setting the data.PROC SQL offers great flexibility for joining tables. |
|
| 25. |
Once You Have Had The Data Read Into Sas Data Sets Are You More Of A Data Step Programmer Or A Proc Sql Programmer? |
|
Answer» It depends on what TYPES of analysis datasets are required for CREATING tables but I am more of a data step programmer as it gives me more flexibility. For e.g creating a change from baseline data set for blood pressure sometimes I have to RETAIN certain values …use arrays ….or use the FIRST. -and last. VARIABLES. It depends on what types of analysis datasets are required for creating tables but I am more of a data step programmer as it gives me more flexibility. For e.g creating a change from baseline data set for blood pressure sometimes I have to retain certain values …use arrays ….or use the first. -and last. variables. |
|
| 26. |
Tell Me About Your Sql Experience? |
|
Answer» I have used the SAS/ACCESS SQL pass thru FACILITY for CONNECTION with external databases and importing tables from them and also Microsoft access and excel files.Besides this, lot of times I have used PROC SQL for joining tables. I have used the SAS/ACCESS SQL pass thru facility for connection with external databases and importing tables from them and also Microsoft access and excel files.Besides this, lot of times I have used PROC SQL for joining tables. |
|
| 27. |
Have You Ever Used Proc Sql For Data Stigmatization? |
|
Answer» Yes I have used it for summarization at times…For e.g if I have to CALCULATE the max value of BP for PATIENTS 101 102 and 103 then I USE the max (bpd) function to get the maximum value and use group by STATEMENT to group the patients ACCORDINGLY. Yes I have used it for summarization at times…For e.g if I have to calculate the max value of BP for patients 101 102 and 103 then I use the max (bpd) function to get the maximum value and use group by statement to group the patients accordingly. |
|
| 28. |
What Are The Three Types Of Join? |
|
Answer» The THREE types of join are inner join, left join and RIGHT join. The inner join option TAKES the MATCHING values from both the tables by the ON option. The left join SELECTS all the variables from the first table and joins second table to it. The right join selects all the variables of table b first and join the table a to it. The three types of join are inner join, left join and right join. The inner join option takes the matching values from both the tables by the ON option. The left join selects all the variables from the first table and joins second table to it. The right join selects all the variables of table b first and join the table a to it. |
|