Sas Master Avinash

You might also like

You are on page 1of 6

BASICS OF SAS

1.Infile statement to include external file save in harddrive ;

2.dbms means data base management system it tell what type of data you are dealing with either csv txt

Ex if you have a raw data nitish ,2000,26,52 then dbms=csv as there is comma separated files

If nitish 2000 26 52 then dbms=dlm(delimeter) means spaces etc.

Delimiter or spaces given between records to keep each variable in specified column.

Delimiter are dlm,csv,dsd,pipeline denoted by I.

Dlm=dsd=,(comma).

EX-data employees;
infile datalines dlm='.'dsd ;
input name$ age salary tax;
rename tax=fuck;
cards;
avin...15. 2000. 5.6
keshri... 14. 4000.2.1
sonam. 21.. 20000. 2.3
keshri. 22. 50000. 4.5
;
run;
proc print data=employees;
TITLE "WORK RADIO SURVEY";
RUN;

DIFFERENCE BETWEEN DSD AND DLM.:-1.dsd helps in reading missing value.2-DSD IS USED WHEN
THERE IS MISSING VALUES IN COLUMN .IT HELPS IN FILTERING NAME WITH QUOTATION MARK EX-
“JOHN”.IT READS TWO CONSECUTIVE DELIMETER AS MISSING VALUES.

Proc import datafile=’file name’ out-to give your own name dbms=csv

3.IT DOESN’T MATTER HOW MANY DELIMETER IS THERE IN BETWEEN TWO VALUES BUT DELIMITER
SHOULD BE SAME.

Sas names not longer than 32.

Comments are used .* and it shud end with ; or /*** and end with ****/

Rename is used for renaming variables .

Ex data students ;
input age gender $ marks;
rename age=height ; /***i purposefully changed it ***/
datalines;
5.4 Male 25
6 Female 26
5.1 Female 21
;
run;
proc print data=students;
run;

data type and format

name=john

date related problems-to solve it format and informat ex 3980integer is given


as birthday date wich shows the days .

to rread this we

import and export data;

1.interactive wizard

2.proc import .
SAS MASTER AVINASH

Basic information

Form of program

1. Data trail; here semicolon acts as a statement terminator if not use it will consider it as data

2. Length gender$ 15; 15 is number of characters it consider. Number is entered up to 12 after that it
will consider in decimal points

3. Input pid age gender$; input makes them variable names

4. Datalines;

100 20 male

200 30 female

300 6 male

Run;

Note-rules to create variables -1 should start with letter

2. Should not use numbers at first place.

3. Should not use special character except _underscore.

4. It should d be 32 characters it should not cross 32

5._null_ data files will not be created hence sas memory will save ex data _nulls_;

Sas data set is tabular form with rows having observations and column contains and variables.

Sas program consists of two steps –data steps and proc steps

Proc steps consists of performing statistical analysis method after which print is done

Programming character to be noted down-Statements to be used

Input-this code follows the rows element under which you want to put values

Datalines-this code will reads your values that’s gonna come in columns
$-it is before character values to tell sas that character names will come under this ex –input age cost
gender $ where dollar sign tell that character values come under gender not numerics.sas cannot
recognize characters.

Length-

Set

If –To differ datas on the base of characters it may be gender wise or number wise ex if Gender=”Male”;

This if will only shows male in rows and columns.

Input data

Variables are separated by space or delimiter ex

Data sets avinash;

Input name $ age grade;

Datalines;

Jack 19 89 here space or delimiter is used.

Proc print data = trail; it gives your program output where proc means procedure.

Run;

Proc content data=trail; it gives you information when the contents was created etc information.

Run;

Proc freq data=trail; freq code will calculate the number of males or females or etc.

Run;

Proc Gchart data=trail; this codes gives a brief preview of your program in the form of graph
Vbar3d gender;

Run;

Types of input methods-

1. list input methods-names and values in same order ex

data list;

input name$ age gender$;

datalines;

john 12 male

run

What if john jhonsan to be consider like this then use input name:& 20. Age gender$ where and sign is
ampercent that considers name with blank space.

2. Column input method-in column input method there is no particular order of writing values under
datalines ex

data col;

Input names$ age gender;

datalines;

21 john male- #here values not mentioned according to the input values.

Run; so numbering used ex name$ 1-6

3. Formatted input method-no need to give column position .here we give character position

Ex –input @10 name$ 12. Here@10 says from where the character values start and 12 says ending
character.

Ex data format;

Input @10 name$ 12 . @1 age 2. @6 gender$ 4. @10 fname$ 4. @15 lname$ 7.

4. Named input method-here name is used

Ex data named;

Input name=$ age= gender=$;

Datalines;
Name=john age=40 gender=male;

5. Output data.

Data out;

Name=’john’; age=40; gender=’male’; outpuT

SAS IF DATA IS MISSING: INFILE OPTIONS-FLOWOVER.MISSOVER.SCANOVER.DLM.DSD

infile datalines flowover;


input center$ trial$ ub;
datalines;
appolo phase 48
nims 56
care phase3 89
nims phae2 66
care phase3 51
;
run;

IMPORTING DATA IN SAS SOFTWARE-

TO IMPORT CSV FILE-

If then/else –statement uses

Syntax if <condition1>then <statement>; ex if English>60 then avg=(English+maths)/2);

You might also like