Thursday 25 February 2016

These are some of the tricky questions that are frequently asked in SAS interview : Epoch Research Institute India Pvt. Ltd. (www.epoch.co.in)

These are some of the tricky questions that are frequently asked in SAS interview : EpochResearch Institute India Pvt Ltd. (SASAuthorised Training : Ahmedabad | Bangalore)

SAS_training


So I am introducing some of the tricky questions that is being asked in SAS interviews frequently. This post will surely give a kick start with those tricky questions that I wanted to introduce to you. Keep a note in mind that the content that I am discussing here is based on information that I have collected online through different SAS sources.

1.    Merging data in SAS
One of the most important steps is merging datasets. This can be done both i.e. data step as well as PROC SQL. Now let’s take an example.



SAS_training


As shown, we have two tables one gives info regarding the product holding for a particular household. The second table shows the gender of customer in household. The male prejudiced product is the one that is bought more by the male. Now let’s understand the code for the same. Initially you have to merge the two tables and we need two Cartesian products for the same. Next you have to summarize the merged dataset and get find the bias. I have displayed the two codes for the same below:

First code:
          Proc sort data = PROD out =A1; by household;run;
          Proc sort data = GENDER out =A2; by household;run;
          Data MERGED;
          merge A1(in=a) A2(in=b);
          by household;
          if a AND b;
          run;

Second code:
          PROC SQL;
          Create table work.merged as
          select t1.household,  t1.type,t2.gender
          from prod as t1, gender as t2
          where t1.household = t2.household;
          quit;

Here you won’t get the same output because here the two tables have many-to-many mappings. In order to get Cartesian product, we need to use PROC SQL.

Use DATA-MERGE step at all as it is much faster compared to PROC SQL

2.    Transpose the data-set
We frequently transpose the datasets to analyze the data when working on transaction data. Here there are two kinds of transposition. First transposition is narrow to wide structure whereas second one is wide to narrow structure. Let’s have a look below



SAS_programming



DATA STEP

PROC TRANSPOSE

So both the transposition are equally good when using such transposition.

Now second one is wide to narrow structure: Consider the below example that is simply opposite to previous one






Here in such transposition, data step becomes too time consuming. So to make the task shorter

         Proc transpose data=transposed out=base (drop=_name_) prefix Q;
         by cust;
         id period;
         var amount;
         run;

3.    Passing of values from one routine to another routine
Let’s say for an example we have two classes and ultimately at the end we want to find out which class has scored highest marks. 



SAS_Advanced_programming



So there are two methods for doing the same. Initially join the two tables and simply sum the total marks. But just imagine if the number of students is large? So in such case, we need a method to pass the value from one table to another

          DATA _null_;set class_1;
          total + marks;
          call symputx ('class1_tot',total);
         run;
         DATA _null_;set class_2;
         total + marks;
         call symputx ('class2_tot',total);
         run;
         DATA results;
         If &class1_tot > &class2_tot then better_class = 1;
         else if &class1_tot > &class2_tot then better_class = 2;
         else better_class = 0;
         run;

From the above code, you can see one function symputx. It creates a macro variable that can be passed between routines and thus allow to link data sets

So this were my thoughts. Have you came across with some SAS problems and interview? Do you have any specific problem with coding? What is your opinion regarding the methods that are used above? Is there are any more convenient ways? Share your thoughts

----->>>>>>>>>>>>>>SAS training<<<<<<<<<<<<<<<<--------
Epoch Research Insitute Links:

Email us: info@epoch.co.in
SAS Training & Placement Programs with Internship: Epoch Research Institute India Largest and Oldest #SASTraining Institute (#epochsastraining)

EPOCH RESEARCH INSTITUTE OFFERS:
Authorized SAS TRAINING | SAS CERTIFICATION | SOFTWARE PURCHASE | BUINESS CONSULTING | TECHNICAL SUPPORT ON SAS || SAS STAFFING SOLUTION 

Label:
#SASELEARNING,#SASELEARNING,#SASONLINETRAINING,
#SASONLINETRAININGFORBEGINNERS,#LEARNSASPROGRAMMINGONLINE,
#SASCLINICALONLINETRAINING,#SASBASEONLINETRAINING
#BIGDATASASTRAININGEPOCH,#SASBIGDATATRAINING #EPOCHRESEARCHINSTITUTE, #SASTRAINING, #EPOCH SAS FEEDBACK,
#CLINICALSASPROGRAMMING, #EPOCHCLINICALSASPROGRAMMING.

No comments:

Post a Comment

How to code in Python with SAS 9.4 by Epoch Research Institute

The SAS® platform is now open to be accessed from open-source clients such as Python, Lua, Java, the R language, and REST APIs to leverage...