SAS and its different syntax

 

 

 

Q. How to convert a Excel sheet in SAS as source ?

A. We cannot use Excel as  a source directly in SAS. It has to be converted to a SAS Data Set and only then can be used in your SAS Analysis.PROC IMPORT is the function which is used to convert the excel data to SAS Subset

Code for importing Excel data and using it as SAS Subset.

Here below I am creating a BOX PLOT using Excel data.

FILENAME REFFILE ‘/home/jethina0/SAS_Codes/case0101.csv’;

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.IMPORTS;
GETNAMES=YES;
RUN;
proc sort data=work.imports; by descending source;run;

PROC PRINT DATA=WORK.IMPORTS; RUN;
PROC BOXPLOT DATA=WORK.IMPORTS;
PLOT SCORE*TREATMENT;
RUN;

 

Q. How to create a Subset of Data in SAS ?

A. Subset of data can be created by using the IF and WHERE Statements

Code 

DATA SMALL;
SET MYSASLIB.CARS;
WHERE ENGINESIZE<2.0;

PROC PRINT DATA=SMALL N=’Total number of cars :’
obs=’Brand’;
title “This is a SMALL Subset”;
RUN;

Here  Engine Size is the filter condition used to create the Subset

 

Q. What are the different ways to call a data in SAS  ?

A. There are multiple ways to do it. The basic one is as follows

CODE

  1. DATA MYDATA;

           INFILE ‘C/SASDATA/CARS’;

  1. PROC SORT DATA=”/home/jethina0/somedata” out=sort1;by descending id;
    RUN;
    PROC PRINT data=sort1 ; RUN;
  2. PROC PRINT DATA =’/home/jethina0/somedata’;
    RUN;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s