Monday, 30 December 2013

General Date and Time Functions On SAS

datepart – Extract date from date time value
dateonly = datepart(fulldate);
day,month year – Extract part of a date value
day = day(date);
dhms – Construct value from date, hour, minute and second
dtval = dhms(date,9,15,0);
mdy – Construct date from month, day and year
date = mdy(mon,day,1996);
time – Returns the current time of day
now = time();
today – Returns the current date
datenow = today();
intck – Returns the number of intervals between two values
days = intck(’day’,then,today());
intnx – Increments a value by a number of intervals
tomrw = intnx(’day’,today(),1);

Wednesday, 18 December 2013

Difference In Excel, Access & SAS


Description
Advantages
Disadvantages

Excel
§Data manipulation and analysis program for which the user provides cell-based data and instructions to produce numerical and graphical output
§Cell-based model creation
§Ability to model "what-if" scenarios
§Comprehensive graphing and print formatting functions
§Basic functionality for novice users (extended greatly if you know macros)


Access
§Data storage and retrieval program for which the user provides record and table-based data and instructions to produce numerical, textual (typically tabular) and graphical output 
 §  Ability to:
Structure complex and interrelated data
Run complex queries on data
Develop customer applications
§Substantial setup time for structuring data and creating tables
§Can't easily manipulate data in individual cells

SAS
§High-power record and table-based data analysis tool for managing queries and statistical analysis
§More powerful analytic functions
§Limited applicability and access to program
  

Tuesday, 17 December 2013

SAS Question- Replace ' Mr ' with 'Dr' in a dataset.

Example 1.

              Data a;
               input name $ 1-15;
                     new_name=prxchange('s/\Mr /Dr /i',-1,name);
            cards;
        Mr Mridul
         Mr Mrinda
       ;run;

Example 2.
     

            data test;
            length have want1 want2 $20;
            have=' Mr Mridul';
           want1=tranwrd(have,'Mr ','Dr ');
          want2=prxchange('s/^ *Mr\b/Dr/oi',1,have);
       run;


Example 3.

             DATA a;
                 INPUT name $ 1-15;
           DATALINES;
           Mr Mridul
            Mr Mrinda
          ;;
         RUN;

Example 4.

          DATA a;
         SET a;
          name = TRANWRD(SCAN(name, 1, ' '), 'Mr', 'Dr ') || SCAN(name, 2, ' ');
         RUN;


SAS Code for Question When a blue moon Occure?

When there are two full moons in a single month, the second is
known as a blue moon. Given that July 9, 1998 is a full moon, and
there are 29 days between full moons, in what months will the next
few blue moons occur?


Solution-- 

data fullmoon;
date = ’09jul98’d;
do i=1 to 500;
month = month(date);
year = year(date);
output;
date = intnx(’day’,date,29);
end;
run;


Now we can use the put function to create a variable with the full month name and the year.

data bluemoon;
set fullmoon;
by year month;
if last.month and not first.month then do;
when = put(date,monname.) || ", " || put(date,year.);
output;
end;
run;
proc print data=bluemoon noobs;
var when;
run;   

Thursday, 12 December 2013

Base SAS Certification Question Papers With Answers

Click here to download Base SAS question paper 1.
Click here to download Base SAS question paper 2.

 To download Advance SAS question paper 1 Click here
 To download Advance SAS question paper 2 Click here