1 / 21

BASIC PROGRAMMING FOR DATA ANALYSIS

BASIC PROGRAMMING FOR DATA ANALYSIS. Dr. D. Dutta Roy Psychology Research Unit Indian Statistical Institute 203, B.T. Road Kolkata- 700108. CONTENTS. Introduction :

anakin
Download Presentation

BASIC PROGRAMMING FOR DATA ANALYSIS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BASIC PROGRAMMING FOR DATA ANALYSIS Dr. D. Dutta Roy Psychology Research Unit Indian Statistical Institute 203, B.T. Road Kolkata- 700108

  2. CONTENTS • Introduction: • Definition, Types of Programming languages, Characteristics of good algorithm, Flowchart,Programming structure , Data analysis • Data entry: File handling, reading and printing data, Array, Operators, Commands,Data entry, Statements, Adv.functions • Data computation :Max score, • result reporting Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  3. What is BASIC ? • BASIC is an useful programming languages for data entry, data analysis and reporting the result. In programming, there are three languages: Machine level/low level (High state and low state or 1 and 0) and higher level languages. BASIC is a higher level language. BASIC means “ Beginner’s All Purpose Symbolic Instructions Code. Computer does not understand the higher level language so higher level language is converted to machine language. Between these two languages, assembly level language exists. It involves a set mnemonic codes. BASIC is simple and easy-to-learn language, particularly suitable for the non-specialist users. Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  4. What is Programming ? • Programming is a set of commands or statements given to the computer in some computer language. These commands will be executed by the computer in a particular sequence. The list of commands given to the computer for solving a problem is called computer program.Any program written in high level language has to be translated into machine language before it is executed by the computer. This can be achieved with the help of translator programs - compilers (translating entire program and executing the program)and interpreters (translating each step and executing it). BASIC programs are normally interpreted not compiled. Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  5. Algorithms • Algorithm is a step-by-step procedure for solving a given problem. The characteristics of good algorithm are: • They are simple but offer powerful and general solutions • They are well documented to be used and easily understood by others • They can be modified easily • They give correct solutions • They save computer time and memory space. • They can be used as sub-procedures for other problems. Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  6. Flow chart • Flow charting is a diagrammatic representation of the problem solving process, in which decision steps are laid out in logical order. Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  7. Operators Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  8. Programming Structure • Array creation • Opening the input,output,append file • Input/read data • Analysis of data as per programming flow • Displaying the output through file or through display unit as per user requirement • End Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  9. ARRAY Array is used to store a large amount of data temporarily to different variables. There are two types of array: One dimensional array and two dimensional array. Syntax of one dimensional array Dim <arrayname> (max.data number) Dim Data (10) Syntax of Two dimensional array Dim <arrayname> (max.row, max.col.) Dim Data (10,5) Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  10. Opening and Closing FilesInput and Output statement Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  11. BASIC STATEMENT COMMANDS Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  12. TRANSFER STATEMENT • GOTO <LINE NO.> • GOSUB <LINE NO.> . . . RETURN Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  13. Conditional statement(IF-THEN) • IF-THEN-ELSE • IF condition 1 THEN statement block 1 ELSE IF condition 2 THEN statement block 2 ELSE statement block n ENDIF Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  14. Conditional statement(ON GOTO) • ON EXPRESSION% GOTO LINE LIST. • ON EXPRESSION% GOSUB LINE LIST. Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  15. Conditional statement(SELECT) Co Select case <variable name> case is >= 1 statement block1 case 2 to 4 statement block2 case 1 statement block 3 end select Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  16. Flow of BASIC program • There are three types of flow in writing the program: • Sequential flow(working instructions sequentially) • Repetitive flow(doing same job repeatedly) • Conditional repetitive flow(Flow depends upon satisfaction of condition) Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  17. Data analysis • There are three phases of data analysis: • Data entry: data coding and feeding to computer, data tabulation and verification • Data analysis: selection of useful measurement techniques and writing program • Display of results: Displaying the data following user’s specification Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  18. DATA ENTRY AND CODING • CLS • REM This program is for entering the data and coding the variables • OPEN "c:\windows\desktop\test.dat" FOR APPEND AS #1 • LOC1 = 1 • LOC2 = 2 • 10 INPUT "NAME OF STUDENTS ", NAME$ • IF NAME$ = "0" THEN GOTO 100 • INPUT "AGE ", AGE • INPUT "LOCALITY (TYPE U FOR URBAN AND R FOR RURAL) ", LOC$ • INPUT "MATHEMATICS EXAM. SCORE ", MATH • IF LOC$ = "U" THEN WRITE #1, NAME$, AGE, LOC1, MATH • IF LOC$ = "R" THEN WRITE #1, NAME$, AGE, LOC2, MATH • GOTO 10 • 100 END Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  19. Advance Functions Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  20. A matrix is a rectangular array of numbers. In matrix algebra, the array is considered to be a single unit rather than collection of individual entries, and is operated upon as a unit. For calculation of two matrices, there should be the same number of rows and columns. A = 105 63 5 218 80 2 220 76 1 84 102 4 B = 240 121 1 302 28 0 Matrix Manipulation Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

  21. REM program to add matrices of two sets of data DIM a(3, 3), b(3, 3), c(3, 3) n = 3: m = 3 FOR i = 1 TO n FOR j = 1 TO m READ a(i, j) DATA 105,63,5,218,80,2,220,76,1 PRINT a(i, j) NEXT j NEXT i PRINT "=========================================" FOR k = 1 TO n FOR l = 1 TO m READ b(k, l) DATA 84,102,4,240,121,1,302,28,0 PRINT b(k, l) NEXT l NEXT k FOR mr = 1 TO n FOR mc = 1 TO m c(mr, mc) = a(mr, mc) + b(mr, mc) NEXT mc NEXT mr PRINT”+++++++++++++++++++++++++” FOR g = 1 TO n FOR h = 1 TO m PRINT c(g, h) NEXT h NEXT g Addition of two matrices Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

More Related