# SAS Coding From Basic To Advanced BY - Aniket Suresh Marwade Remember -- - ROWS are called Observations. - Columns are called Variables. - In SAS each line of code ends with semicolon. - SAS is insensitive to case (means you can write anyway like Data, data, dAtA all will give same result). - SAS is insensitive to indentation (means in simple words it is not like python :smiling_face_with_smiling_eyes_and_hand_covering_mouth: ) ------------------- **Example 1:** Creating a Dataset. ```sas Data Test; /*Dataset or Table*/ a=1; /*Variable or Columns and their value*/ Run; ``` --------------- **Example 2:** Create a data set that contains 3 variables. ```sas Data Number; Var1 = 123; Var2 = 356; Var3 = 923; Run; ``` **Output:** ![image](https://hackmd.io/_uploads/rJ4qKdCcp.png) -------------- #### Creating Character Variables Unlike other programming languages such as R, Java or C++, there are only two types of variable in SAS: * Numeric * Character Creating a character variable is easy. You simply need to enclose them with a quotation mark. Either single quotation ('John') or double quotation ("John") works. **Example 3:** Create a dataset where you have character and numeric variables. ```sas Data Food; Restraunt = "Burger King"; Num_of_Employee = 5; Location = "Mumbai"; Run; ``` **Output :** ![image](https://hackmd.io/_uploads/ry5QaOC5p.png) ------- #### Creating Multiple Observations(Rows). The majority of the SAS data sets contain multiple observations (Rows). ![data_sets_1042](https://hackmd.io/_uploads/HkQJhKA5p.png) In order to create a data set that contains more than one observation, you need the Input and Datalines statements. #### Input and Datalines Statement Here in the below code, * *Input* - lists variables(columns) to be created. * *Datalines* - it signals SAS to begin reading the data on the next line. **Example:** Create a dataset with 3 obervation. ```sas Data Test1; Input a b c; Datalines; 1 3 4 2 7 9 12 45 56 ; Run; ``` **Output:** ![image](https://hackmd.io/_uploads/B1sWMcA9T.png) #### Creating multiple obervations(Rows) for character using Input and Datalines.