Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ADBMS LAB FILE                AMITY SCHOOL OF ENGINEERING AND TECHNOLOGYSubmitted By:                          Submitted T...
Program No:1WAP to input data in SASData student;Input Rollno,name$;Datalines23 parul24 payal25 priyaProc print data=stude...
Program No:2WAP to input data into SAS using external text fileData one;Infile "C:Documents and SettingsAdministratorDeskt...
Output:
Program No:3WAP to list a file using delimiter commaOption Nocentre;data demo;Infile "C:Documents and SettingsAdministrato...
Program No:4WAP to demonstrate the use of columns in SASData financial;Infile "C:Documents and SettingsAdministratorDeskto...
Program No:5WAP to demonstrate the use of IN operator in SASdata quizlange;length gender$1 quiz$2;input age gender midterm...
Program No:6WAP to demonstrate the Square and Square Root in SASdata table;do n=1 to 10;square=n+n;squareroot=sqrt(n);outp...
Program No:7WAP to demonstrate the use of select operator in SASdata conditional;length gender$1 quiz$2;input age gender m...
OUTPUT:
Program No:8WAP to demonstrate the Use of sum statements & iterative Do loop operator in SAS.data compound;interest =0.315...
Program No:9WAP to demonstrate the Use of If operator in SASData females;length gender$1 quiz$2;Input age gender midterm q...
Program No:10WAP to demonstrate the Use of If and else-if operator in SAS.Data conditional;length gender$1 quiz$2;Input ag...
Program No:11WAP to demonstrate the Use of Do loop in SAS.data grades;length gender$1 quiz$2 agegrp$13;infile "C:Documents...
Output:
Program No:12WAP to demonstrate the Use of Do while loop in SAS.data double;interest=0.0375;total=100;do whiel(total le 20...
OUTPUT:
Program No:13WAP to demonstrate the Use of Do until loop in SAS.data double;interest=0.0375;total=100;do until(total ge 20...
OUTPUT:
Program 14:WAP to demonstrate the Use of leave and continue statement in SASLeave Statement:data leave_it;interest=0.0375;...
Continue Statement:data continue_on;interest=0.0375;total=100;do year=1 to 100;total=total+interest*total;if total le 5000...
OUTPUT:
Adbms lab file
Adbms lab file
Upcoming SlideShare
Loading in …5
×

Adbms lab file

975 views

Published on

14 BASIC programs in SAS

Published in: Technology, Sports
  • Be the first to comment

  • Be the first to like this

Adbms lab file

  1. 1. ADBMS LAB FILE AMITY SCHOOL OF ENGINEERING AND TECHNOLOGYSubmitted By: Submitted To:Name: Punit Tripathi Faculty Guide: Ms. Parul Kalra BhatiaClass/Section: 7 IT2 YProgramme: Btech-IT (2008-2012)Enrolment Number: A2305308127
  2. 2. Program No:1WAP to input data in SASData student;Input Rollno,name$;Datalines23 parul24 payal25 priyaProc print data=student;Output:
  3. 3. Program No:2WAP to input data into SAS using external text fileData one;Infile "C:Documents and SettingsAdministratorDesktoprishabstuff1.txt";Input x y;Datalines;Data two;input x y;Datalines;4567;Data three;set one two;Proc print data=three;
  4. 4. Output:
  5. 5. Program No:3WAP to list a file using delimiter commaOption Nocentre;data demo;Infile "C:Documents and SettingsAdministratorDesktoprishabmydata.txt" dsd;input gender$ age height weight;Title"Listing :The file with delimiter comma";Proc print data=demo;Output:
  6. 6. Program No:4WAP to demonstrate the use of columns in SASData financial;Infile "C:Documents and SettingsAdministratorDesktoprishabBank.txt";input subj 1-3 dob$ 4-13gender$ 14 balance 15-18;Title"Demonstrating Columns"Proc print data=financial;Output:
  7. 7. Program No:5WAP to demonstrate the use of IN operator in SASdata quizlange;length gender$1 quiz$2;input age gender midterm quiz finalexam;if quiz in(A+ A B+ B) then quizrange=1;else if quiz in(B- C+ C) then quizrange=2;datalines;21 M 80 B 92 F 80 B+ 9322 F 90 B 9423 M 91 C- 9525 F 92 C+ 96run;Title "Quiz-Range";proc print data=quizlange;OUTPUT:
  8. 8. Program No:6WAP to demonstrate the Square and Square Root in SASdata table;do n=1 to 10;square=n+n;squareroot=sqrt(n);output;end;run;proc print data=table;run;OUTPUT:
  9. 9. Program No:7WAP to demonstrate the use of select operator in SASdata conditional;length gender$1 quiz$2;input age gender midterm quiz finalexam;if age lt 20 and not missing(age) then agegroup=1;else if age ge 20 and age lt 40 then agegroup=2;else if age ge 40 and age lt 60 then agegroup=3;else if age ge 60 then agegroup=4;select(agegroup);when(1) limit=110;when(2) limit=120;when(3) limit=130;otherwise;end;datalines;21 M 80 B 9224 F 80 B+ 9322 F 90 B 9423 M 91 C- 9525 F 92 C+ 96;proc print data=conditional;
  10. 10. OUTPUT:
  11. 11. Program No:8WAP to demonstrate the Use of sum statements & iterative Do loop operator in SAS.data compound;interest =0.315;total=100;do year=1 to 3;total= total+interest;output;end;format total dollar10.2;run;proc print data=compound;OUTPUT:
  12. 12. Program No:9WAP to demonstrate the Use of If operator in SASData females;length gender$1 quiz$2;Input age gender midterm quiz finalexam;if gender eq F;Datalines;21 M 30 B 8220 F 90 A 9322 F 89 B 9423 M 92 A 95;Proc print Data=females;OUTPUT:
  13. 13. Program No:10WAP to demonstrate the Use of If and else-if operator in SAS.Data conditional;length gender$1 quiz$2;Input age gender midterm quiz finalexam;if age lt 20 and not missing(age) then age group=1;else if age ge 20 and age lt 40 then age group=2;else if age ge 40 and age lt 60 then age group=3;else if age ge 60 then age group=4;Datalines;21 M 30 B 8220 F 90 A 9322 F 89 B 9423 M 92 A 95;Proc print Data=conditional;OUTPUT:
  14. 14. Program No:11WAP to demonstrate the Use of Do loop in SAS.data grades;length gender$1 quiz$2 agegrp$13;infile "C:Documents and Settingsstudent1DesktopSASGrades.txt" missover;input age gender midterm quiz final_exam;if missing(age) then delete;if age le 39 then do;agegrp=younger gr;grade=0.4*midterm+0.6*final_exam;end;else if age gt 39 then do;agegrp=older grp;grade=(midterm+final_exam)/2;end;run;title "listing of grades";proc print data=grades;run;
  15. 15. Output:
  16. 16. Program No:12WAP to demonstrate the Use of Do while loop in SAS.data double;interest=0.0375;total=100;do whiel(total le 200);year+1;total=total+interest*total;output;end;format total dollar10.2;run;title"use of do while ";proc print data=double;run;
  17. 17. OUTPUT:
  18. 18. Program No:13WAP to demonstrate the Use of Do until loop in SAS.data double;interest=0.0375;total=100;do until(total ge 200);year+1;total=total+interest*total;output;end;format total dollar10.2;run;title "use of do until ";proc print data=double;run;
  19. 19. OUTPUT:
  20. 20. Program 14:WAP to demonstrate the Use of leave and continue statement in SASLeave Statement:data leave_it;interest=0.0375;total=100;do year=1 to 100;total=total+interest*total;output;if total ge 200 then leave;end;format total dollar10.2;run;title"leave statement";proc print data=leave_it;run;OUTPUT:
  21. 21. Continue Statement:data continue_on;interest=0.0375;total=100;do year=1 to 100;total=total+interest*total;if total le 5000 then continue;end;title"continue statement";proc print data=continue_on;format total dollar10.2;run;
  22. 22. OUTPUT:

×