Data analysis 1 (Introduction)

Click to compare with Python equivalents

Stata users

How to open Stata:

Mac: Press Command + Space, type Stata, press Enter
Windows: Press Windows Key, type Stata, press Enter

Python users

How to open the terminal:

Mac: Press Command + Space, type Terminal, press Enter
Windows: Press Windows Key, type PowerShell, press Enter

Python runs inside this environment.

Manipulating directories

    pwd
    ls
    cd zemi
    mkdir zemi

command [action]
1.1 pwd [ prints working directory ]
1.2. ls [ displays available files in current directory ]
1.3. mkdir name [ creates new directory name ]
1.4. cd directory_path [ move to directory ]

To check your working directory just type:

    pwd    

Let's move to the home directory and print the working directory. Type:

    cd ~/
    pwd

Now let's make a directory called 'zemi' and move into that directory. And verify our location. Type:

    mkdir zemi
    cd zemi
    pwd

*** Absolute versus relative paths ***

Absolute path: a complete path to a file or directory from the root directory. The root directory is the top-level directory of the file system

Relative path:: a path to a file or directory that is relative to the working directory. It specifies the location of the file or directory in relation to the working directory

To move up 1 directory relatively:

    cd ..

Move back into your zemi directory:

    cd zemi

Open Python

After returing to the zemi directory, open python:

    python

or:

    python3

Your first program

command [action]
1.5. display [ displays strings and values of scalar expressions ]
command [action]
1.5. print [ prints strings and values of scalar expressions ]

    display "hello world"    

print("hello world")

    display hello world    

print(hello world)

    display "2+2"    

print("2+2")

    display 2+2    

print(2+2)