Sas guidelines

  • 832 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
832
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
81
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. /*EXCEL FILE*//*IN EXCEL WE CANT DO THE IMPORT USING PROGRAMMINGAPPROACH*/ /*PROC STEP BLOCK*/PROC IMPORT DATAFILE=C:Documents andSettingsAdministratorDesktopSIMPLE.XLS OUT=GNANI.EXCEL DBMS=EXCEL REPLACE;RUN; /*IF THE DATA SECOND SHEET IN EXCEL FILE */PROC IMPORT DATAFILE=C:Documents andSettingsAdministratorDesktopEXCEL.XLS OUT=GNANI.SIMPLE DBMS=EXCEL; SHEET=SHEET2; GETNAMES=YES;RUN; /*IF THE DATA IN MIDDLE OF THE SHEET*/PROC IMPORT DATAFILE=C:Documents andSettingsAdministratorDesktopRANGE.XLS OUT=GNANI.RANGE1 DBMS=EXCEL; RANGE=SHEET1$F17:H18; GETNAMES=NO;RUN;OPTIONS LS=154 PS=200; /*WORD DOCUMENT*/FILENAME SIMPLE DDE WINWORD|"C:Documents andSettingsAdministratorDesktopSIMPLE.DOC"!JAYALALITHA;DATA NG;INFILE SIMPLE FIRSTOBS=2;INPUT ID NAME $ AGE ;RUN;PROC PRINT;RUN; /* TO EXPORT USING NULL VARIABLE*/ /*EXPORTING*/DATA _NULL_;FILE C:ASH.TXT;PUT @25 THIS IS SIMPLE DATA;PUT @10 ID @20 NAME @40 AGE;RUN;DATA _NULL_;SET NG;FILE C:ASH.TXT MOD;PUT @10 ID @20 NAME @40 AGE;
  • 2. RUN; /*TO EXPORT USING PROC BLOCK*/ /*TEXT DOCUMENT*/PROC EXPORT OUTFILE=C:EXP.TXT DATA=SASHELP.CLASS DBMS=DLM;RUN; /*EXCEL FILE*/PROC EXPORT OUTFILE=C:EXPO.XLS DATA=SASHELP.PROFIT DBMS=EXCEL;RUN;/*TO REPORT COMPANIES INFO WHO HAS BEENESTABLISHED IN BANG AND INVEST>30000000 ANDYEAR 1997*/PROC SQL;SELECT * FROM SASHELP.PROFITWHERE AREA=BAN AND INVEST>300000 AND YEAR=1997;QUIT;/*USED OR OPERATOR*/PROC SQL;SELECT * FROM SASHELP.PROFITWHERE AREA EQ BAN OR INVEST GT 300000 OR YEAR EQ 1997;QUIT;/*USED BETWEEN OPERATOR**/PROC SQL;SELECT * FROM SASHELP.PROFITWHERE INVEST BETWEEN 30000000 AND 40000000;QUIT;/*IN OPERATOR*/PROC SQL;SELECT * FROM SASHELP.PROFITWHERE COMPANY IN(ACENTURE,TCS);QUIT;/*NOTE:ALL OPERATOR CAN USED INPROC SQL PROCEDURE.*//*ORDER BY CLAUSE*(BEDEFAULT ASCENDING)*/PROC SQL;SELECT * FROM SASHELP.PROFIT ORDER BY COMPANY;QUIT;/*TO ORDER DESCENDING ORDER*/PROC SQL;SELECT * FROM SASHELP.PROFIT ORDER BY COMPANY DESC;QUIT;/*SORTING BASED ON THE POSITION ANDTO STORE NEW TABLE*/PROC SQL;CREATE TABLE NEW_TABLE ASSELECT * FROM SASHELP.PROFIT ORDER BY COMPANY;QUIT;/*GROUP BY COMPANY*/PROC SQL;CREATE TABLE NEW_GROUP AS
  • 3. SELECT * FROM SASHELP.PROFIT GROUP BY COMPANY;QUIT;/*HAVING CLAUSE*/PROC SQL;CREATE TABLE NEW_GROUP1 ASSELECT * FROM SASHELP.PROFIT GROUP BY COMPANY HAVING INVEST>40000000;QUIT;/*TO USE MULTIPLE CLAUSES IN ONE SELECTSTATEMENT*/quit;PROC SQL;CREATE TABLE MULT_CLA ASSELECT * FROM SASHELP.PROFITWHERE YEAR IN(1996) AND COMPANY EQ ACENTURE ORDER BY AREA;QUIT;/*AGGREGATE FUNCTION*//* TO REPORT TOTAL NO OF PATIENS HAD TAKEN TRT IN DIFFERENT CINTERS*//* EG FOR COLUMN WISE*/proc sql;select sum(age) as total_sum from sashelp.class;quit;/*FOR ROW WISE*/proc sql;select *,sum(age,height) as total_sum from sashelp.class;quit;/*TO REPORT MAX NO OF PATIENTS HAD TAKEN TRT INDIFFERENT TRTMTS IN CENTER*//*FOR COLUMN WISE*/proc sql;select *,max(age) as total_sum from sashelp.class;quit;/*FOR ROW WISE*/proc sql;select *,max(age,weight) as total_sum from sashelp.class;quit;/*TO REPORT MIN NO*//*FOR COLUMN WISE*/proc sql;select *,min(age) as total_sum from sashelp.class;quit;/*FOR ROW WISE*/proc sql;select *,min(age,WEIGHT) as total_sum from sashelp.class;quit;/*STD(STANDARD DEVIATION)*/proc sql;select *,STD(age) as total_sum from sashelp.class;quit;proc sql;select *,STD(HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,STD(WEIGHT) as total_sum from sashelp.class;quit;
  • 4. proc sql;select *,STD(age,HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,STD(WEIGHT,HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,STDERR(AGE) as total_sum from sashelp.class;quit;proc sql;select *,STDERR(AGE,HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,MEDIAN(AGE) as total_sum from sashelp.class;quit;proc sql;select *,MEDIAN(AGE,HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,MEDIAN(WEIGHT,HEIGHT) as total_sum from sashelp.class;quit;proc sql;select *,LENGTH(NAME) as total_sum from sashelp.class;quit;proc sql;select *,INDEX(NAME,a) as total_sum from sashelp.class;quit;/*PASS THROUGH FACILITY*//*CREATE THE TABLE IN OTHER ENVIRONMENTUSING SAS ENVIRONMENT*/PROC SQL;CONNECT TO EXCEL(PATH=C:SALES.XLS);EXECUTE (CREATE TABLE SALES_PROD5 (ID INT, PROD CHAR , LOCATION CHAR, PROFIT CHAR)) BY EXCEL;EXECUTE(INSERT INTO SALES_PROD5 VALUES (1021,DOMESTIC,INDIA,45000)) BY EXCEL;DISCONNECT FROM EXCEL;QUIT; /*EXCEL FILE*//*CONNECT INTO THE CREATED EXCEL FILE FROM SAS*/PROC SQL;CONNECT TO EXCEL(PATH=C:GNANISALES.XLS);EXECUTE (CREATE TABLE SALES_PROD5 (ID INT, PROD CHAR , LOCATION CHAR, PROFIT CHAR)) BY EXCEL;EXECUTE(INSERT INTO SALES_PROD5 VALUES (1021,DOMESTIC,INDIA,45000)) BY EXCEL;DISCONNECT FROM EXCEL;QUIT;
  • 5. /*UPDATE THE DATAVALUE INTOTHE EXISTED TABLE USING SAS ENVIRONMENT*/PROC SQL;CONNECT TO EXCEL (PATH=D:ANNA.XLS);EXECUTE(UPDATE GD_ANNA SET AGE=AGE+1 ) BY EXCEL;DISCONNECT FROM EXCEL;QUIT;PROC SQL;CONNECT TO EXCEL(PATH=C:MAA.XLS);EXECUTE(UPDATE EMP_TABLE SET AGE=AGE+2 WHERE NAME=JEEVAN)BY EXCEL;DISCONNECT FROM EXCEL;QUIT;PROC SQL;CONNECT TO EXCEL(PATH=C:MAA.XLS);EXECUTE(UPDATE EMP_TABLE SET AGE=AGE+3 WHERE NAME IN (KIRAN,JEGEN)BYEXCEL;DISCONNECT FROM EXCEL;QUIT;/*IMPORTING THE DATA AND STORING INTO NEW TALE*/PROC SQL;CONNECT TO EXCEL (PATH=C:MAA.XLS);CREATE TABLE NEW_EMP ASSELECT * FROM CONNECTION TO EXCEL(SELECT * FROM EMP_TABLE);SELECT * FROM NEW_EMP;QUIT;/*TO INSERT FOR EXISTED TABLE */PROC SQL;CONNECT TO EXCEL(PATH=C:MAA.XLS);EXECUTE(INSERT INTO EMP_TABLE VALUES(214,A,40)) BY EXCEL;DISCONNECT FROM EXCEL;QUIT;/*ANALYSIS*/ /*BASE SAS PROCEDURE*/ /*FORMAT PROCEDURE*//*EG FOR CREATE USERDEFINED FORMAT FORCONVERTING TO CHAR*/PROC FORMAT;VALUE GEN 1=MALE 2=FEMALE 3=OTHERS ;RUN;/*TO APPLY THE USERDEFINEDFORMAT TO THE GENDER VARIABLES*/DATA SAMPLE;INPUT EID ENAME $ GENDER;FORMAT GENDER GEN.;DATALINES;111 A 1222 B 2333 C 1444 D 2555 E 3666 F 2777 G 1888 H 1;
  • 6. PROC PRINT;RUN;/*TO CREATE USERDEFINED INFORMAT FORCONVERTING NUMERIC TO NUMERIC*/PROC FORMAT;INVALUE GEO 1=5234 2=4789 3=3984 ;RUN;DATA SAMPLE;INPUT EID ENAME $ GENDER;INFORMAT GENDER GEO.;DATALINES;111 A 1222 B 2333 C 1444 D 2555 E 3666 F 2777 G 1888 H 1;PROC PRINT;RUN;/*TO CONVERT CHARACTER TO CHARACTER TO DEFINE THEUSERDEFINED INFORMAT*/PROC FORMAT;INVALUE $ ENM A=JOHN B=KIRAN C=RAM D=UMA E=GIRI ;RUN;DATA STDT;INPUT EID ENAME : $ ENM. GENDER;DATALINES;111 A 1222 B 2333 C 1444 D 2555 E 3666 F 2777 G 1888 H 1;PROC PRINT;RUN;/*FOR EXTERNAL FILE PURPOSE TO APPLY THEINFORMAT AND FORMAT USING FUNCTIONS*/PROC FORMAT;VALUE GED 1=MALE 2=FEMALE ;VALUE $ CR W=WHITE B=BLACK;
  • 7. RUN;DATA NW3;SET CLIN;FORMAT COLOR CR. GENDER GED.;RUN;PROC PRINT;RUN;/*FOR EXTERNAL FILE PURPOSE TO APPLY THEINFORMAT AND FORMAT USING FUNCTIONS*/PROC FORMAT;VALUE GED 1=MALE 2=FEMALE ;VALUE $ CR W=WHITE B=BLACK;RUN;DATA NW4;SET CLIN;GEND=PUT(GENDER,GED.);COL=PUT(COLOR,CR.);RUN;PROC PRINT;RUN; /*TO CONVERTS THE ANY VARIABLE DATA VALUE INTO CHARACTER VARIABLE OR NUMERIC VARIANLE*/DATA CL3(DROP=GENDER);SET CLIN(RENAME=(GENDER=GENDER3));IF GENDER3=1 THEN GENDER=MALE;IF GENDER3=2 THEN GENDER=FEMALE;RUN;PROC PRINT;RUN;/*EG FOR INPUT FUNCTION*/PROC FORMAT LIBRARY=SASUSER;INVALUE $ RC A=1 B=2 C=3 ;RUN;OPTIONS FMTSEARCH=(SASUSER);DATA STDT;INPUT SID SNAME $ GRD $ TEST1 TEST2;GRD=INPUT(GRD,$GD.);DATALINES;111 A a 36 67222 B b 45 56333 C c 43 45232 D d 45 56;PROC PRINT;RUN;/*EG FOR INPUT FUNCTION*/PROC FORMAT;INVALUE $ RC AS=1 AF=2 OT=3
  • 8. ;RUN;DATA PAT;SET CLIN;NEW_RACE=INPUT(RACE,$RC.);RUN;PROC PRINT;RUN;/*BOTH FUNCTION ARE USED IN FORMAT PROCEDURE*/PROC FORMAT;VALUE GEO 1=MALE 2=FEMALE ;INVALUE CO W=1 B=2 ;RUN;DATA P;SET PATI;GEND=PUT(GENDER,GEO.);COLO=INPUT(COLOR,CO.);RUN;PROC PRINT;RUN; /*PICTURE STATEMENT*/ /*EG FOR SYNTAX*/PROC FORMAT;PICTURE RES LOW-35=FAIL 35-60=SECOND 60-70=THIRD 70-HIGH=DIST ;RUN;DATA STDT;INPUT SRN SNAME $ AGE MARK;FORMAT MARK RES.;DATALINES;222 A 23 67432 B 35 78746 C 23 90743 D 21 20472 E 19 45;PROC PRINT;RUN;PROC FORMAT;VALUE PA 120-<80=NORMAL 90-<70=LOW 110-<75=MEDIUM 140-<90=HIGH ;RUN;DATA PATI3;INPUT PID PNAME $ DBPSBP CENTER;FORMAT DBPSBP PA.;DATALINES;352 SIRU 130 APPOLO
  • 9. 342 VIRU 90 GH235 KIRU 70 APPOLO374 NAREN 140 GH;PROC PRINT;RUN;/*PRINTTO PROCEDURE*//*EG FOR SENDING THE LOG WINDOW FOR CLIENTDESIRED LOCATION*/PROC PRINT DATA=CLA;RUN;PROC PRINTTO FILE=C:MAA.TXT;RUN;PROC PRINT DATA=CLA;RUN;PROC PRINTTO FILE=C:MA.XLS;RUN;DATA EMP;INPUT EID $ ENAME $ SALARY COMPANY $;DATALINES;WI234 MENAKA 40000 WIPROSY344 LAVANYA 35000 SYNTEL;PROC PRINT DATA=EMP;RUN;PROC PRINTTO LOG=C:LAT.XLS;RUN;/*WE ARE EXPORTING IN THE FORM OFRTF (RICH TEXT FORMAT*/DATA DAT1;SET SASHELP.CLASS;RUN;PROC PRINT;RUN;PROC PRINTTO FILE=C:GNANI.RTF;RUN;PROC PRINTTO LOG=C:GNAN.RTF;RUN;/*PDF(PORTABLE DOCUMENT FORMAT*/PROC PRINTTO FILE=C:VIJAY.PDF;RUN;PROC PRITTO LOG=C:VIJA.PDF;RUN;/*HTML (HYPERTEXT MARKUP LANGUAGE)*/PROC PRINTTO FILE=C:LAK;RUN;PROC PRINTTO LOG=C:LAK;RUN; /*SAS-ANALYSIS*/DATA STUD_PERF;INPUT SRN $ GENDER $ PHY CHEM MATHS LOCATION $ INST $ NOS;DATALINES;001 M 66 55 18 HYD A 67003 F 45 68 87 CHEN B 78005 F 56 87 40 BAN A 56
  • 10. 004 M 90 50 40 CUL A 76009 F 76 78 56 HYD B 87007 M 67 40 57 CHEN C 56006 F 48 29 57 BAN A 65002 M 65 34 90 CHEN C 65569 F 87 57 47 BAN A 54758 M 67 56 45 CHEN B 67547 F 67 58 98 BAN C 87649 F 78 38 58 CHEN B 54587 M 78 45 57 BAN B 56533 F 78 56 45 HYD C 55785 M 45 89 67 CUL B 35875 F 34 32 30 HYD B 56587 M 45 49 70 CHEN B 44578 F 67 45 89 BAN C 67;RUN;PROC PRINT;RUN;/*BY DEFAULT REPORT USING MEANS STATEMENT*/PROC MEANS DATA=STUD_PERF;RUN;/*TO REPORT ONE NUMERIC VAR ANALYSIS WITHCLASSIFICATION VAR*/PROC MEANS DATA=STUD_PERF;VAR MATHS;CLASS GENDER;RUN;OPTIONS LS=120;/*TO REPORT TWO OR MORE VARIBLE ANALYSIS WITHCLASS VAR*/PROC MEANS DATA=STUD_PERF;VAR MATHS PHY CHEM;CLASS GENDER;RUN;/*MULTIPLE CLASS VAR WITH MULTIPLE NUMERICVAR*/PROC MEANS DATA=STUD_PERF;VAR MATHS PHY CHEM;CLASS GENDER INST;RUN;/*TO APPLY THE MEANS STATEMENT OPTIONS*/PROC MEANS DATA=STUD_PERF RANGE N CV SKEWNESS;RUN;/*TO APPLY STMTS AND OPTIONS IN BOTH INONE PROGRAM*/
  • 11. PROC MEANS DATA=STUD_PERF MEAN MIN MAX RANGE N CV SKEWNESS;VAR PHY;CLASS LOCATION;RUN;OPTIONS LS=150;/*TO REPORT THE STATISTICAL MEASUREMENTSBASED ON THE CLASSIFICATION*//*TO GENERATE THE SEPARATE ANALYSIS BASED ONTHE CONDITION*/PROC SORT DATA=STUD_PERF;BY GENDER;RUN;PROC MEANS DATA=STUD_PERF STDDEV RANGE SKEWNESS KURTOSIS Q1 Q3 P10 P50;VAR PHY CHEM MATHS;CLASS GENDER;BY GENDER;RUN;/*TO GENERATE THE REPORT BASED ON THE CONDITIONAND SEPARATED ANALYSIS*/PROC SORT DATA=STUD_PERF;BY GENDER;RUN;PROC MEANS DATA=STUD_PER ;VAR PHY CHEM MATHS;CLASS GENDER;BY GENDER;WHERE PHY GE 60;RUN;/*TO SAVE THE OUTPUT IN ONE DATASET*/PROC MEANS DATA=STUD_PERF;OUTPUT OUT=STAT_MEASURE;RUN;/*TO GENERATE STAT MESUREMENTS IN ONLY DATASETNOT IN OUTPUT*/PROC MEANS DATA=STUD_PERF NOPRINT;OUTPUT OUT=STAT_MEASURE1;RUN;/*TO GENERATE STAT MEASUREMENTS IN ONLYDATASET NOT IN OUTPUT*/PROC MEANS DATA=STUD_PERF;OUTPUT OUT=STATS_MEASURE3 MEAN=MIN_PER RANGE=RANGE_PER P10=PERC_PER;RUN;
  • 12. /*TO INCREASE THE ANALYSIS TYPES IN DATASETTHEN WE APPLY VAR AND CLASS STMT IN PROCMEANS PROCEDURE*/PROC MEANS DATA=STUD_PERF NOPRINT;VAR PHY CHEM MATHS;CLASS GENDER;OUTPUT OUT=STATS_MEA5 MEAN=MEAN_PER RANGE=RANGE_PER P10=PERC_PER;RUN;/*TO INCREASE THE ANALYSIS TYPES IN DATASETTHEN WE APPLY VAR AND CLASS STMT IN PROCMEANS PROCEDURE*/PROC MEANS DATA=STUD_PERF NOPRINT;VAR PHY CHEM MATHS;CLASS GENDER INST;OUTPUT OUT=STATS_MEA9 MIN=MEAN_PER MAX=MAX_PER MEAN=MEAN_PER;RUN; /*NWAY OPTION*/PROC MEANS DATA=STUD_PERF NOPRINT NWAY;VAR PHY CHEM MATHS;CLASS GENDER INST;OUTPUT OUT=STATS_MEA13 MIN=MIN_PER MAX=MAX_PER MEAN=MEAN_PER STDERR=SE_PER;RUN; /*WE HAVE TO TAKE ONE DATASET FROM OUR SASHELP LIBRARY*//*BY DEFAULT REPORT USING MEANS STATEMENT*/PROC MEANS DATA=SASHELP.PROFIT;RUN;/*TO REPORT ONE NUMERIC VAR ANALYSIS WITHCLASSIFICATION VAR*/PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST;CLASS COMPANY;RUN;/*TO REPORT TWO OR MORE VARIBLE ANALYSIS WITHCLASS VAR*/
  • 13. PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST ACT_PROFIT EST_PROFIT;CLASS COMPANY;RUN;/*MULTIPLE CLASS VAR WITH MULTIPLE NUMERICVAR*/PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST ACT_PROFIT EST_PROFIT;CLASS COMPANY AREA;RUN;/*TO APPLY THE MEANS STATEMENT OPTIONS*/PROC MEANS DATA=SASHELP.PROFIT MEAN MIN MAX RANGE N CV SKEWNESS;RUN;/*TO APPLY STMTS AND OPTIONS IN BOTH INONE PROGRAM*/PROC MEANS DATA=SASHELP.PROFIT MEAN MIN MAX RANGE N CV SKEWNESS;VAR INVEST;CLASS COMPANY;RUN;/*TO REPORT THE STATISTICAL MEASUREMENTSBASED ON THE CLASSIFICATION*//*TO GENERATE THE SEPARATE ANALYSIS BASED ONTHE CONDITION*/PROC SORT DATA=SASHELP.PROFIT;BY COMPANY;RUN;PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST ACT_PROFIT EST_PROFIT;CLASS COMPANY;BY COMPANY;RUN;/*TO GENERATE THE REPORT BASED ON THE CONDITIONAND SEPARATED ANALYSIS*/PROC SORT DATA=SASHELP.PROFIT;BY COMPANY;RUN;PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST ACT_PROFIT EST_PROFIT;CLASS COMPANY;BY COMPANY;WHERE INVEST >40000000;RUN;
  • 14. /*TO SAVE THE OUTPUT IN ONE DATASET*/PROC MEANS DATA=SASHELP.PROFIT;OUTPUT OUT=STAT_PROFIT;RUN;/*TO GENERATE STAT MESUREMENTS IN ONLY DATASETNOT IN OUTPUT*/PROC MEANS DATA=SASHELP.PROFIT NOPRINT;OUTPUT OUT=STAT_PROFIT1;RUN;/*TO GENERATE STAT MEASUREMENTS IN ONLYDATASET NOT IN OUTPUT*/PROC MEANS DATA=SASHELP.PROFIT ;OUTPUT OUT=STATS_PROFIT2 MEAN=MEAN_PRO RANGE=RANGE_PRO P10=PERC_PRO;RUN;/*TO INCREASE THE ANALYSIS TYPES IN DATASETTHEN WE APPLY VAR AND CLASS STMT IN PROCMEANS PROCEDURE*/PROC MEANS DATA=SASHELP.PROFIT NOPRINT;VAR INVEST ACT_PROFIT EST_PROFIT;CLASS AREA;OUTPUT OUT=STATS_PR5 MEAN=MEAN_PR RANGE=RANGE_PR P10=PERC_PR;RUN;/*TO INCREASE THE ANALYSIS TYPES IN DATASETTHEN WE APPLY VAR AND CLASS STMT IN PROCMEANS PROCEDURE*/PROC MEANS DATA=SASHELP.PROFIT NOPRINT;VAR INVEST ACT_PROFIT;CLASS COMPANY AREA;OUTPUT OUT=STATS_PR7 MIN=MIN_PR MAX=MAX_PR MEAN=MEAN_PR;RUN; /*NWAY OPTION*/PROC MEANS DATA=SASHELP.PROFIT PRINT NWAY;VAR INVEST ACT_PROFIT;CLASS COMPANY AREA;OUTPUT OUT=STATS_PR8 MIN=MIN_PR MAX=MAX_PR MEAN=MEAN_PR;
  • 15. RUN; /*FREQUENCY PROCEDURE*/DATA SAMPLE;INPUT RESULT $ @@;DATALINES;Y Y Y N N Y N Y N Y N N YY N N Y N Y N N Y Y N Y NN Y N N Y N Y N N Y N Y N YN Y N Y Y N Y N N Y Y Y N Y N;PROC FREQ DATA=SAMPLE;RUN;/*TO REPORT THE ONE VARIABLE ANALYSIS WITH FREQPROCEDURE*/PROC FREQ DATA=STUD_PER;TABLES PHY;RUN;/*TO REPORT THE CHARACTOR VARIABLE ANALYSISWITH FREQ PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES GENDER;RUN;/*ANALYSIS OF TWO NUM AND MORE CHAR VARUSING TWO TABLE STMT PROC FREQ PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES PHY CHEM;TABLES GENDER LOCATION;RUN;/*ALL WILLBE IN TABLE STATEMENT*/PROC FREQ DATA=STUD_PERF;TABLES PHY CHEM GENDER LOCATION;RUN;/*TO SAVE THE FREQ OUTPUT IN ONE DATASET*/PROC FREQ DATA=STUD_PERF;TABLES PHY CHEM GENDER LOCATION/OUT=LO;RUN;/*CROSS TABULATION ANALYSIS USING FREQ PROC*/PROC FREQ DATA=STUD_PERF;TABLES GENDER*LOCATION;RUN;OPTIONS PS=300;/*TO DO THE CROSS TABULATION ANALYSIS WITH SEPARATEDGROUPS*/
  • 16. PROC SORT DATA=STUD_PERF;BY GENDER;RUN;PROC FREQ DATA=STUD_PERF;TABLES LOCATION*GENDER;BY GENDER;RUN; /*MISSING OPTION IN FREQ PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES GENDER/MISSING;RUN;/*CROSS TABULATION ANALYSIS WITH MULTIPLEVARIABLES*/PROC FREQ DATA=STUD_PERF;TABLES SRN*LOCATION*GENDER;RUN;/*CROSS TAB ANALYSIS WITH COMBINATION*/PROC FREQ DATA=STUD_PERF;TABLES SRN*(GENDER LOCATION);RUN;/*NO ROW NOCOL OPTIONS IN FREQ PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES SRN*(GENDER LOCATION)/NOROW NOCOL;RUN;/*CROSS TABULATION ANALYSIS WITH MULTIPLECOMBINATION*/PROC FREQ DATA=STUD_PERF;TABLES (SRN LOCATION)*(INST GENDER);RUN;/*TO GENERATE TJE CHI-SQUARE STAT FOR RECQUIRED VARIBLEIN FREQ PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES PHY/CHISQ;RUN;/*WEIGHT STMT IN FREQUENCY PROCEDURE*/PROC FREQ DATA=STUD_PERF;TABLES SRN PHY;WEIGHT PHY;RUN; /*WE HAVE TO TAKE ONE DATASET FROM OUR LIBRARY*//*TO REPORT THE ONE VARIABLE ANALYSIS WITH FREQPROCEDURE*/
  • 17. PROC FREQ DATA=SASHELP.PROFIT;TABLES INVEST;RUN;/*TO REPORT THE CHARACTOR VARIABLE ANALYSISWITH FREQ PROCEDURE*/PROC FREQ DATA=SASHELP.PROFIT;TABLES AREA;RUN;/*ANALYSIS OF TWO NUM AND MORE CHAR VARUSING TWO TABLE STMT PROC FREQ PROCEDURE*/PROC FREQ DATA=SASHELP.PROFIT;TABLES ACT_PROFIT EST_PROFIT;TABLES AREA COMPANY;RUN;/*ALL WILLBE IN TABLE STATEMENT*/PROC FREQ DATA=SASHELP.PROFIT;TABLES ACT_PROFIT EST_PROFIT AREA COMPANY;RUN;/*TO SAVE THE FREQ OUTPUT IN ONE DATASET*/PROC FREQ DATA=SASHELP.PROFIT;TABLES ACT_PROFIT EST_PROFIT AREA COMPANY/OUT=COM;RUN;/*CROSS TABULATION ANALYSIS USING FREQ PROC*/PROC FREQ DATA=SASHELP.PROFIT;TABLES AREA*COMPANY;RUN;/*TO DO THE CROSS TABULATION ANALYSIS WITH SEPARATEDGROUPS*/PROC SORT DATA=SASHELP.PROFIT;BY COMPANY;RUN;PROC FREQ DATA=SASHELP.PROFIT;TABLES AREA*COMPANY;BY COMPANY;RUN;/*CROSS TABULATION ANALYSIS WITH MULTIPLEVARIABLES*/PROC FREQ DATA=SASHELP.PROFIT;TABLES INVEST*AREA*COMPANY;RUN;/*CROSS TAB ANALYSIS WITH COMBIANTION*/PROC FREQ DATA=SASHELP.PROFIT;
  • 18. TABLES INVEST*(AREA COMPANY);RUN;/*NO ROW NOCOL OPTIONS IN FREQ PROCEDURE*/PROC FREQ DATA=SASHELP.PROFIT;TABLES INVEST*(AREA COMPANY)/NOROW NOCOL;RUN;OPTIONS PS=300;/*CROSS TABULATION ANALYSIS WITH MULTIPLECOMBINATION*/PROC FREQ DATA=SASHELP.PROFIT;TABLES (AREA INVEST)*(COMPANY ACT_PROFIT);RUN;/*TO GENERATE TJE CHI-SQUARE STAT FOR RECQUIRED VARIBLEIN FREQ PROCEDURE*/PROC FREQ DATA=SASHELP.PROFIT;TABLES COMPANY/CHISQ;RUN;/*WEIGHT STMT IN FREQUENCY PROCEDURE*/PROC FREQ DATA=SASHELP.PROFIT;TABLES AREA INVEST;WEIGHT INVEST;RUN; /*TABULATE PROCEDURE*//*TO REPORT THE TOTAL NO OF STUDENTS IN VARIOUSINSTS FROM THE ABOVE TABLE*/PROC TABULATE DATA=STUD_PERF;VAR NOS;TABLE NOS;RUN; /*FREQUENCY ANALYSIS*/PROC TABULATE DATA=STUD_PERF;CLASS NOS;TABLE NOS;RUN; /*FREEQUENCY ANALYSIS(CHAR VALUE IN CLASSSTMT*/PROC TABULATE DATA=STUD_PERF;CLASS GENDER;TABLE GENDER;RUN;/*SEPARATED ANALYSIS USING BY STMT IN TABUALAE
  • 19. PROCEDURE*/PROC SORT DATA=STUD_PERF;BY LOCATION;RUN;PROC TABULATE DATA=STUD_PERF;BY LOCATION;CLASS LOCATION;TABLE LOCATION;RUN;/*TO REPORT THE TOTAL NO OF STUDENTS INTODIFFERENT LOCATION*/PROC SORT DATA=STUD_PERF;BY LOCATION;RUN;PROC TABULATE DATA=STUD_PERF;BY LOCATION;VAR NOS;CLASS LOCATION;TABLE LOCATION NOS;RUN;/*TO REPORT THE TOTAL NO OF MARKS, TOT NO STUD,WITH THE SPECIFIED CLASSIFICATION*/PROC SORT DATA=STUD_PERF;BY GENDER;RUN;PROC TABULATE DATA=STUD_PERF;BY GENDER;VAR NOS PHY MATHS;CLASS GENDER;TABLE GENDER NOS PHY MATHS;RUN;/*TO REPORT THE TOT NO OF STUD TOT NO OF MARKSWITH MULTIPLE TYPES OF CLASS VARIBLES*/PROC SORT DATA=STUD_PERF;BY GENDER LOCATION;RUN;PROC TABULATE DATA=STUD_PERF;BY GENDER LOCATION;VAR NOS PHY MATHS;CLASS GENDER LOCATION;TABLE GENDER NOS PHY MATHS LOCATION;RUN;/*DIMENSION PROCEDURE IN TABULATE PROCEDURE*/PROC TABULATE DATA=STUD_PERF;CLASS GENDER LOCATION;TABLE GENDER,LOCATION/BOX=REP BETWEEN GEND AND LOC;RUN;
  • 20. /*MULTIPLE DIMENSIONS*/PROC TABULATE DATA=STUD_PERF;VAR NOS;CLASS GENDER LOCATION;TABLE NOS,GENDER,LOCATION/BOX=REP BERWEEN THE NOS GEND AND LOC;RUN;/*TO GENERATE THE DIMENSION WITH CROSSTABULATION*//*TO REPORT TOT QTY FROM D/F LOCATION ANDD/F GENDER*/PROC TABULATE DATA=STUD_PERF;VAR NOS;CLASS GENDER LOCATION;TABLE GENDER*LOCATION,NOS;RUN;/*TO REPORT THE MULTIPLE VARIABLE CROSSTABULATION WITH DIMENSION REPORT*/PROC TABULATE DATA=STUD_PERF;VAR NOS;CLASS GENDER LOCATION INST;TABLE GENDER*LOCATION*INST,(NOS ALL);RUN;/*FORMAT OPTION IN TABULATE PROCEDURE*/PROC TABULATE DATA=STUD_PERF FORMAT=15.;VAR NOS;CLASS GENDER LOCATION INST;TABLE GENDER*LOCATION*INST,(NOS ALL);RUN;/*OUT OPTION IN TABULATE PROC*/PROC TABULATE DATA=STUD_PERF OUT=NEW_REP ;VAR NOS;CLASS GENDER LOCATION INST;TABLE INST*GENDER*LOCATION,(NOS ALL);RUN;/*TO GENERATE THE DESCRIPTIVE STAT IN TABULAR FORMAT FORREQ VAR*/PROC TABULATE DATA=STUD_PERF OUT=NEW_DESC;VAR NOS;TABLE NOS*(SUM MEAN MEDIAN NMISS N STDDEV);RUN;/*TO GENERATE DESCRIPTIVE STAT WITH CLASSIFICATIONVAR FOR SUMMARY DATA*/
  • 21. PROC TABULATE DATA=STUD_PERF OUT=NEW_DESC1;VAR NOS;CLASS GENDER;TABLE GENDER,NOS*(SUM MEAN MEDIAN NMISS N STDDEV);RUN; /*KEYLABEL*/PROC TABULATE DATA=STUD_PERF;VAR NOS;CLASS LOCATION;TABLE(NOS,ALL),LOCATION;KEYLABEL ALL=TOTAL;RUN; /*WE HAVE TO TAKE FROM OUR LIB*//*TO REPORT THE TOTAL NO OF STUDENTS IN VARIOUSINSTS FROM THE ABOVE TABLE*/PROC TABULATE DATA=SASHELP.DATA_MIN;VAR QTY;TABLE QTY;RUN; /*FREQUENCY ANALYSIS*/PROC TABULATE DATA=SASHELP.DATA_MIN;CLASS QTY;TABLE QTY;RUN; /*FREQUENCY ANALYSIS*/PROC TABULATE DATA=SASHELP.DATA_MIN;CLASS QUALIFICATION;TABLE QUALIFICATION;RUN;/*SEPARATED ANALYSIS USING BY STMT IN TABUALAEPROCEDURE*/PROC SORT DATA=SASHELP.DATA_MIN;BY AREA;RUN;PROC TABULATE DATA=SASHELP.DATA_MIN;BY AREA;CLASS AREA;TABLE AREA;RUN;/*TO REPORT THE TOTAL QTY INTODIFFERENT LOCATION*/PROC SORT DATA=SASHELP.DATA_MIN;BY AREA;RUN;PROC TABULATE DATA=SASHELP.DATA_MIN;BY AREA;VAR QTY;CLASS AREA;
  • 22. TABLE AREA QTY;RUN;/*TO REPORT THE TOTAL QTY, RATEWITH THE SPECIFIED CLASSIFICATION*/PROC SORT DATA=SASHELP.DATA_MIN;BY PRODUCT_ID ;RUN;PROC TABULATE DATA=SASHELP.DATA_MIN;BY PRODUCT_ID ;VAR RATE QTY;CLASS PRODUCT_ID ;TABLE PRODUCT_ID RATE QTY ;RUN;/*TO REPORT THE TOT NO OF QTY TOT NO OF RATEWITH MULTIPLE TYPES OF CLASS VARIBLES*/PROC SORT DATA=SASHELP.DATA_MIN;BY PRODUCT_ID AREA ;RUN;PROC TABULATE DATA=SASHELP.DATA_MIN;BY PRODUCT_ID AREA;VAR RATE QTY;CLASS PRODUCT_ID AREA;TABLE PRODUCT_ID RATE QTY AREA;RUN;OPTIONS LS=200;/*DIMENSION PROCEDURE IN TABULATE PROCEDURE*/PROC TABULATE DATA=SASHELP.DATA_MIN;CLASS AREA ITEM_TYPE;TABLE AREA ITEM_TYPE;RUN;/*TO GENERATE THE DIMENSION WITH CROSSTABULATION*//*TO REPORT TOT QTY FROM D/F LOCATION ANDD/F GENDER*/PROC TABULATE DATA=SASHELP.DATA_MIN;VAR QTY;CLASS AREA GENDER ITEM_TYPE;TABLE AREA*GENDER*ITEM_TYPE,(QTY ALL);RUN; /*KEYLABEL*/PROC TABULATE DATA=SASHELP.DATA_MIN;VAR QTY;CLASS AREA;TABLE(QTY,ALL),AREA;KEYLABEL ALL=TOTAL;RUN; /*REPORT PROCEDURE*/ /*BY DEFAULT STMTS OF PROC REPORT*/
  • 23. PROC REPORT DATA=STUD_PERF;RUN; /*KEEP OPTIONS*//*(KEEP OPTIONS ONLY USED IN RESULT WINDOW ONLY)*/PROC REPORT DATA=STUD_PERF (KEEP=SRN GENDER LOCATION INST);RUN;OPTIONS LS=100; /*NO WINDOW OPTION*//*TO REPORT THE OUTPUT IN TRADITIONAL OUTPUTWINDOW */PROC REPORT DATA=STUD_PERF NOWD;RUN; /*HEADSKIP*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP;RUN; /*HEADSKIP IN RESULT WINDOW*/PROC REPORT DATA=STUD_PERF HEADSKIP;RUN; /*HEADLINE*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;RUN;OPTIONS LS=150; /*SPACING OPTION*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE SPACING=8;RUN; /*COLUMNS STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;RUN; /*GROUP WITH DEFINE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/GROUP;RUN; /*ACROSS WITH DEFINE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/ACROSS;RUN;
  • 24. /*ORDER WITH DEFINE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/ORDER;RUN; /*DESCENDING WITH DEFINE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN INST PHY GENDER;DEFINE GENDER/GROUP;DEFINE GENDER/DESCENDING;RUN; /*MULTIPLE DEFINE STMTS USED*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY LOCATION;DEFINE GENDER/ORDER;DEFINE LOCATION/ACROSS;RUN; /*BREAK STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/GROUP;BREAK AFTER GENDER/OL UL SUMMARIZE;RUN; /*SUPPRESS OPTIONS*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/GROUP;BREAK AFTER GENDER/OL UL SUPPRESS;RUN; /*COMPUTE BLOCK*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/GROUP;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;RUN; /*RBREAK*/OPTIONS PS=300;PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/GROUP;BREAK AFTER GENDER/OL UL SUMMARIZE;
  • 25. COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;RBREAK AFTER/DOL DUL SUMMARIZE;COMPUTE AFTER;GENDER=GTOTAL;ENDCOMP;RUN;/*NEW VAR CREATION IN REPORT PROCEDURE*//*(USING COMPUTE BLOCK)*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY CHEM TOTAL;DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;RBREAK AFTER/DOL DUL SUMMARIZE;COMPUTE AFTER;GENDER=GTOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;RUN; /*CONDITIONAL STMT WITH COMPUTE BLOCK*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY CHEM TOTAL STATUS;DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;DEFINE STATUS/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;RBREAK AFTER/DOL DUL SUMMARIZE;COMPUTE AFTER;GENDER=GTOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;COMPUTE STATUS/CHAR;IF _C4_ GT _C5_ THEN STATUS=GOOD;ELSE STATUS=AVERAGE;ENDCOMP;RUN; /*LINE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP;COLUMNS SRN GENDER INST PHY CHEM TOTAL;
  • 26. DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;DEFINE STATUS/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;COMPUTE BEFORE;LINE --------------------------------------;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE --------------------------------------;ENDCOMP;COMPUTE AFTER;LINE 50*-;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE 50*-;ENDCOMP;RUN; /*BOX OPTION*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP BOX;COLUMNS SRN GENDER INST PHY CHEM TOTAL;DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;DEFINE STATUS/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;COMPUTE BEFORE;LINE --------------------------------------;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE --------------------------------------;ENDCOMP;COMPUTE AFTER;LINE 50*-;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE 50*-;ENDCOMP;RUN; /*OUT OPTION*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP BOX OUT=REP_PERFOR;COLUMNS SRN GENDER INST PHY CHEM TOTAL;DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;DEFINE STATUS/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;
  • 27. GENDER=TOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;COMPUTE BEFORE;LINE --------------------------------------;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE --------------------------------------;ENDCOMP;COMPUTE AFTER;LINE 50*-;LINE THIS IS REPORT BELONGS STDTS PERFORM;LINE 50*-;ENDCOMP;RUN; /*COLOR OPTION*/PROC REPORT DATA=STUD_PERF HEADLINE BOX;COLUMNS SRN GENDER PHY LOCATION;DEFINE GENDER/GROUP COLOR=BLUE;RUN; /*WHERE STMT*/PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY;DEFINE GENDER/ORDER;WHERE PHY>80;RUN; /*CORRELATION PROCEDURE*/ /*NEGATIVE CORRELATION*/OPTIONS LS=120;DATA CORRN;INPUT EXPS SALES @@;DATALINES;4 4 6 78 46 36 35 25 86 32 64 22 64 44;proc print DATA=CORRN;RUN;PROC CORR DATA=CORR;VAR EXPS SALES;RUN; /*POSITIVE CORRELATION*/DATA CORRP;INPUT EXPS SALES @@;DATALINES;4 10 6 12 46 58 35 45 86 98 64 78 64 70;PROC CORR DATA=CORRP;VAR EXPS SALES;RUN;/*TO FINDOUT THE RELATION BETWEEN THE TWO VAR*/
  • 28. DATA CORRP;INPUT EXPS SALES LOCATION $ @@ ;DATALINES;4 10 CHEN 6 12 HYD 46 58 CHEN 35 45 BAN 86 98 BAN 64 78 CUL 64 70 DEL;PROC CORR DATA=CORRP OUTP=P_DS OUTS=S_DS OUTK=K_DS;VAR EXPS SALES;RUN;/*TO GENERATE THE CORRELATION MEASURES FORSEPARATE BY GROUPS*/PROC SORT DATA=CORRP;BY LOCATION;RUN;PROC CORR DATA=CORRP OUTP=P_DS;VAR EXPS SALES;BY LOCATION;RUN;/*WE HAVE TO TAKE DATA FROM OUT SASHELP LIB*/PROC SORT DATA=SASHELP.DMTOOLS;BY GROUP;RUN;PROC CORR DATA=SASHELP.DMTOOLS;BY GROUP;VAR SORT ICON;RUN; /*UNIVARIATE PROCEDURE*/PROC UNIVARIATE DATA=CORRP;RUN; /*WITH VAR STMT*/PROC UNIVARIATE DATA=CORRP;VAR EXPS SALES;CLASS LOCATION;RUN; /*TO GENERATE THE HISTOGRAM USING UNIVARIATEPROCEDURE*/PROC UNIVARIATE DATA=CORRP;HISTOGRAM;RUN; /*BY STMT USED IN UNIVARIATE PROCEDURE*/PROC SORT DATA=CORRP;BY LOCATION;RUN;PROC UNIVARIATE DATA=CORRP;VAR EXPS SALES;BY LOCATION;RUN;/*WE HAVE TO TAKE DATA FROM ONE LIB*/PROC SORT DATA=SASHELP.PROFIT;
  • 29. BY AREA;RUN;PROC UNIVARIATE DATA=SASHELP.PROFIT;VAR INVEST ACT_PROFIT;CLASS COMPANY;BY AREA;RUN; /*SUMMARY PROCEDURE*//*TO GENERATE THE NO OF OBS*/PROC SUMMARY DATA=CORRP PRINT;RUN;/*TO GENERATE DESCRIPTIVE STAT WITH NUMVAR*/PROC SUMMARY DATA=CORRP PRINT;VAR EXPS SALES;CLASS LOCATION;RUN; /*REGRESSION PROCEDURE*//*EG FOR REGRESSION STMT IN SAS SYSTEM*//*IN FIRST WE HAVE TO TAKE SIMPLE PROGRAM*/DATA REGR;INPUT PEXS SALES @@;DATALINES;7 12 10 14 9 14 5 7 11 15 5 9 3 6;PROC REG DATA=REGR;VAR SALES PEXS;MODEL SALES=PEXS;PLOT SALES*PEXS;RUN;PROC REG DATA=REGR;VAR SALES PEXS;MODEL SALES=PEXS;PLOT SALES*PEXS/SYMBOL=*;RUN; /*LOGISTIC REGRESSION*/DATA REGR1;INPUT PEXS SALES PRICE @@;DATALINES;7 12 15 10 14 20 9 14 16 5 7 9 11 15 17 5 9 11 3 6 9;PROC REG DATA=REGR1;VAR SALES PEXS PRICE;MODEL SALES=PEXS PRICE;PLOT SALES*PEXS;PLOT SALES*PRICE;RUN; /*LOGISTIC REPORT*/PROC LOGISTIC DATA=SASHELP.PROFIT;CLASS COMPANY;
  • 30. MODEL INVEST=EST_PROFIT ACT_PROFIT;RUN; /*ODS(OUTPUT DELIVERY SYSTEM)*//*FOR PRINT(LISTING PURPOSE)*/ODS LISTING CLOSE;ODS HTML FILE=D:LIST_PRINT.HTML;PROC PRINT DATA=SASHELP.CLASS;RUN;ODS HTML CLOSE;ODS LISTING; /*FOR LOGISTIC PROCEDURE*/ODS LISTING CLOSE;ODS HTML FILE=D:LIST_PRINT1.HTML;PROC LOGISTIC DATA=SASHELP.PROFIT;CLASS COMPANY;MODEL INVEST=EST_PROFIT ACT_PROFIT;RUN;ODS HTML CLOSE;ODS LISTING; /*FOR MEANS PROCEDURE*/ODS LISTING CLOSE;ODS HTML FILE=D:LIST_MEANS.HTML;PROC MEANS DATA=SASHELP.PROFIT;VAR INVEST;CLASS COMPANY;RUN;ODS HTML CLOSE;ODS LISTING; /*FOR FREQ PROCEDURE*/ODS LISTING CLOSE;ODS RTF FILE=D:LIST_FREQ.RTF;PROC FREQ DATA=SASHELP.PROFIT;TABLES AREA*COMPANY;RUN;ODS RTF CLOSE;ODS LISTING; /*FOR TABULATE PROCEDURE*/ODS LISTING CLOSE;ODS PDF FILE=D:LIST_TAB.PDF;PROC TABULATE DATA=SASHELP.PROFIT;CLASS AREA COMPANY;TABLE AREA,COMPANY/BOX=REP BETWEEN COMP AND LOC;RUN;ODS PDF CLOSE;ODS LISTING; /*REPORT PROCEDURE*/
  • 31. ODS LISTING CLOSE;ODS HTML FILE=D:LIST_REP.HTML;PROC REPORT DATA=STUD_PERF NOWD HEADSKIP HEADLINE;COLUMNS SRN GENDER INST PHY CHEM TOTAL STATUS;DEFINE GENDER/GROUP;DEFINE TOTAL/COMPUTED;DEFINE STATUS/COMPUTED;BREAK AFTER GENDER/OL UL SUMMARIZE;COMPUTE AFTER GENDER;GENDER=TOTAL;ENDCOMP;RBREAK AFTER/DOL DUL SUMMARIZE;COMPUTE AFTER;GENDER=GTOTAL;ENDCOMP;COMPUTE TOTAL;TOTAL=_C4_+_C5_;ENDCOMP;COMPUTE STATUS/CHAR;IF _C4_ GT _C5_ THEN STATUS=GOOD;ELSE STATUS=AVERAGE;ENDCOMP;RUN;ODS HTML CLOSE;ODS LISTING; /*FOR CORRELATION PROC*/ODS LISTING CLOSE;ODS RTF FILE=D:LIST_CORR.RTF;PROC SORT DATA=CORRP;BY LOCATION;RUN;PROC CORR DATA=CORRP OUTP=P_DS;VAR EXPS SALES;BY LOCATION;RUN;ODS RTF CLOSE;ODS LISTING; /*FOR UNIVARIATE PROC*/ODS LISTING CLOSE;ODS PDF FILE=D:LIST_UNI.PDF;PROC SORT DATA=CORRP;BY LOCATION;RUN;PROC UNIVARIATE DATA=CORRP;VAR EXPS SALES;BY LOCATION;RUN;ODS PDF CLOSE;ODS LISTING; /*SUMMARY PROC*/ODS LISTING CLOSE;
  • 32. ODS HTML FILE=D:LIST_SUM.HTML;PROC SUMMARY DATA=CORRP PRINT;VAR EXPS SALES;CLASS LOCATION;RUN;ODS HTML CLOSE;ODS LISTING;PROC PRINT DATA=SASHELP.CLASS;RUN; /*EXPORTING THE LISTING OUTPUT INTO THE RTF FILE FORMAT WITH COLORS*/ /*OBS WITH COLOUR*/ODS LISTING CLOSE;ODS HTML FILE=C:LISTING.HTML;PROC PRINT DATA=SASHELP.CLASSSTYLE(OBS)=[FOREGROUND=BLACK BACKGROUND=PINK];RUN;ODS HTML CLOSE;ODS LISTING; /*OBS AND HEADER WITH COLOUR*/ODS LISTING CLOSE;ODS RTF FILE=C:LISTING1.RTF;PROC PRINT DATA=SASHELP.CLASSSTYLE(OBS)=[FOREGROUND=BLACK BACKGROUND=PINK]STYLE(HEADER)=[FOREGROUND=BLUE BACKGROUND=YELLOW];RUN;ODS RTF CLOSE;ODS LISTING; /*OBS HEADER AND OBSHEADER WITH COLOUR*/ODS LISTING CLOSE;ODS HTML FILE=C:LISTING2.HTML;PROC PRINT DATA=SASHELP.CLASSSTYLE(OBS)=[FOREGROUND=BLACK BACKGROUND=PINK]STYLE(HEADER)=[FOREGROUND=BLUE BACKGROUND=YELLOW]STYLE(OBSHEADER)=[FOREGROUND=GREEN BACKGROUND=BROWN];RUN;ODS HTML CLOSE;ODS LISTING; /*ALL WITH BE COLOUR*/ODS LISTING CLOSE;ODS HTML FILE=C:LISTING3.HTML;PROC PRINT DATA=SASHELP.CLASSSTYLE(OBS)=[FOREGROUND=BLACK BACKGROUND=PINK]STYLE(HEADER)=[FOREGROUND=BLUE BACKGROUND=YELLOW]STYLE(OBSHEADER)=[FOREGROUND=GREEN BACKGROUND=BROWN]STYLE(DATA)=[FOREGROUND=YELLOW BACKGROUND=GREEN];RUN;ODS HTML CLOSE;
  • 33. ODS LISTING; /*PDF FILE FORMAT*/ODS LISTING CLOSE;ODS PDF FILE=C:LISTING4.PDF;PROC PRINT DATA=SASHELP.CLASSSTYLE(OBS)=[FOREGROUND=BLACK BACKGROUND=PINK]STYLE(HEADER)=[FOREGROUND=BLUE BACKGROUND=YELLOW]STYLE(OBSHEADER)=[FOREGROUND=GREEN BACKGROUND=BROWN]STYLE(DATA)=[FOREGROUND=YELLOW BACKGROUND=GREEN];RUN;ODS PDF CLOSE;ODS LISTING; /*T-TEST FOR SINGLE MEAN*/DATA EMPLOY;INPUT EMP_SALARY @@;DATALINES;3000 20003500 15003200 45003200 15003200 12002100 29002300 12001300 2100;PROC TTEST DATA=EMPLOY H0=2400 ALPHA=0.10;VAR EMP_SALARY;RUN; /*T-TEST PROCEDURE FOR DOUBLE MEAN*/DATA SAMPLE;INPUT ENGINEERS ACCOUNTANTS;DATALINES;125 112115 98119 10985 9697 77107 70125 114125 100118 .;PROC TTEST DATA=SAMPLE ALPHA=0.5;VAR ENGINEERS ACCOUNTANTS;RUN; /*TTEST FOR COMPARISON OF GROUP ANALYSIS (MEANS GROUPING ANALYSIS)*/data graze;length GrazeType $ 10;input GrazeType $ WtGain @@;datalines;
  • 34. controlled 45 controlled 62controlled 96 controlled 128controlled 120 controlled 99controlled 28 controlled 50controlled 109 controlled 115controlled 39 controlled 96controlled 87 controlled 100controlled 76 controlled 80continuous 94 continuous 12continuous 26 continuous 89continuous 88 continuous 96continuous 85 continuous 130continuous 75 continuous 54continuous 112 continuous 69continuous 104 continuous 95continuous 53 continuous 2;run;proc sort;by GrazeType;proc means data=graze noprint;var WtGain;by GrazeType;output out=newgraze;run;proc ttest data=newgraze;class GrazeType;var WtGain;run; /*PAIRED SAMPLE TTEST PROCEDURE*/DATA PRESSURE;INPUT OUTLETNO BEFORECOMP AFTERCOMP;DATALINES;1 240 2702 225 2453 250 2604 280 2905 200 1906 150 1607 165 1608 100 1309 130 13510 170 175;PROC TTEST DATA=PRESSURE;PAIRED BEFORECOMP*AFTERCOMP;RUN; /*ANOTHER EXAMPLE*/data pressure;input SBPbefore SBPafter @@;datalines;120 128 124 131 130 131 118 127
  • 35. 140 132 128 125 140 141 135 137126 118 130 132 126 129 127 135;run;proc ttest;paired SBPbefore*SBPafter;run; /*ANOVA PROCEDURE*/data PainRelief;input PainLevel Codeine Acupuncture Relief @@;datalines;1 1 1 0.0 1 2 1 0.5 1 1 2 0.6 1 2 2 1.22 1 1 0.3 2 2 1 0.6 2 1 2 0.7 2 2 2 1.33 1 1 0.4 3 2 1 0.8 3 1 2 0.8 3 2 2 1.64 1 1 0.4 4 2 1 0.7 4 1 2 0.9 4 2 2 1.55 1 1 0.6 5 2 1 1.0 5 1 2 1.5 5 2 2 1.96 1 1 0.9 6 2 1 1.4 6 1 2 1.6 6 2 2 2.37 1 1 1.0 7 2 1 1.8 7 1 2 1.7 7 2 2 2.18 1 1 1.2 8 2 1 1.7 8 1 2 1.6 8 2 2 2.4;proc anova data=PainRelief;class PainLevel Codeine Acupuncture;model Relief = PainLevel Codeine|Acupuncture;RUN; /*SAS/GRAPH-PROCEDURE */ /*VBAR CHART*/data shirts;input Size $ @@;datalines;medium largelarge largelarge mediummedium smallsmall mediummedium largesmall mediumlarge largelarge smallmedium mediummedium mediummedium largesmall small;proc chart data=shirts;vbar size;run; /*HBAR CHART*/proc chart data=shirts;Hbar size;
  • 36. run; /*PIE CHART*/proc chart data=shirts;pie size;run; /*BLOCK CHART*/proc chart data=shirts;BLOCK size;run; /*STAR CHART*/OPTIONS LS=90 PS=100;proc chart data=shirts;STAR size;run;