My SAS Tutorials

Thursday 4 April 2013

SAS INTERVIEWS CONCEPTUAL QUESTIONS VIII

We are reading a raw file:



111 .
.      .
.      .
.      .
.     222


We need  to create a SAS dataset one like this:


                         ONE

Customer_Id            Product_ID
        111                            222


Write most efficient program.(It should be in single datastep) 

Now prepare your Base SAS and Advance SAS Certification Exams with Online Mock tests:  http://exam.sankhyana.com



For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com

6 comments:

  1. data one(drop=customer_id rename=(cust=customer_id));
    retain customer_id cust;

    infile "C:\..\..\test1.dat" end=last;

    input customer_id Product_ID ;

    if customer_id >. then cust= customer_id;
    if last then output;

    run;
    proc print;
    run;

    ReplyDelete
  2. Even smaller step:
    data one;

    input #1 customer_id
    #5 @5 Product_ID ;
    output;

    datalines;
    111 .
    . .
    . .
    . .
    . 222
    ;

    run;

    ReplyDelete
  3. data one;
    infile cards ;
    input a b ;
    if a='.' then a=111;
    if b='.' then b=222;
    put _all_;
    cards;
    111 .
    . .
    . .
    . 222
    ;
    run;
    proc print data=one (obs=1);
    run;

    ReplyDelete
  4. we can use coleasc funbction to this like
    b=coleasc(b)

    ReplyDelete
  5. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care
    http://chennaitraining.in/qliksense-training-in-chennai/
    http://chennaitraining.in/pentaho-training-in-chennai/
    http://chennaitraining.in/machine-learning-training-in-chennai/
    http://chennaitraining.in/artificial-intelligence-training-in-chennai/
    http://chennaitraining.in/snaplogic-training-in-chennai/
    http://chennaitraining.in/snowflake-training-in-chennai/

    ReplyDelete