Posts

Graphs SAS: Ron Cody Book

Image
SAS is a very powerful tool to build the graphs. Our main focus is to build the SAS/Graph like Bar Graphs, Scatter Plots etc.Let us look on some of the questions and try to understand the code and the output. The appearance of the output from various SAS/GRAPH procedures can be influenced by additional statements such as SYMBOL (for example, defines plotting symbols and line styles), PATTERN (defines styles for bar graphs), and AXIS (defines horizontal and vertical axes) Q1) Code: let us understand step wise what is happening 1) Title statement describes the title to be printed. It is a global statement. 2) Ron Cody has specified:    A PATTERN statement requests that the bars in your vertical bar chart consist of an outline only (the default is to fill in the bar).  The VBAR statement requests a vertical bar  Alternatives to VBAR are as follows: HBAR Horizontal bar chart VBAR3D Three-dimensional vertical bar chart H...

Subsetting and Combing the Datasets

Image
In this blog we would look at some programmes on how to do subsetting of the data  and how to combine the data from several to single datasets. Subsetting a SAS datastep involves selecting observations from one data set by defining the selection criteria either where , if/else , select  among many others. Lets look at the questions to get better understanding  Q Code: Code: 1) We are creating a new dataset A35_a in library A15035 2) We are reading the observations from blood dataset in library A15035. 3) We are partitioning the data based on the condition using the where keyword when gender equals female and bloodtype is AB. 4) We are creating the new variable combined computing the value based on the condition specified. 5) Then we are using the proc print to print the observations from the dataset A35_a 6) In the next part we are creating a new dataset A35_b in library A15035 7) We are reading the observations from blood datas...

Performing Conditional Processing Part B: Learning SAS by Example Questions Solved

Image
Hi Folks!! Welcome to the second part of the blog where we would aim at understanding how do conditional formatting helps in "making decisions" based on data values. We have earlier done 1 Question in Part 1 here we would be solving the other 5 Question given in the book Learning SAS by example. Q1) Lets see the code and try to understand the same: Code:           The 1st snippet creates the hospital dataset in the library A15035. Our focus is to understand the use of in and or operator. In and or operator helps in getting the same output. Let us understand after breaking the two codes Proc print is used to print the observations in the A35_hosp dataset from A15035 library where has been  used to put some constraints ordering the command to output the observations based on conditions specified after the where clause Or statement is simply checking if the subject values are 5,100,150 and 200 then only print the obser...

Performing Conditional Processing Part A

Image
Hi Folks Welcome back!!   SAS is a software for various applications like business intelligence, predictive analytics among many others. Lot of companies have deployed this software due to its powerful statistical benefits. As an analyst one must be aware of how we work on this software. For this purpose we are writing this blog. The mode of explanation would be covered via question and answer mode. We are referring to the book Learning SAS by example Programmer's guide by Ron Cody This is a very easy and lucid book . One can refer to in terms of basics and is like a bible for beginners.  Indian Edition costs around Rs-5000 . The topic for this blog is Conditional Formatting : If Else Statement. Q1: Code: Question Requirement: 1) In the above code we are creating a dataset A35_school in library A15035. 2) The attributes are age (numeric) , quiz (character with length 1 denoted as $1),midterm (numeric) and final(numeric) 3)...

SAS Blog 3: Formats and Labels

Image
Welcome to the 3rd set of blog  The topic under discussion is formats and labels. The SAS gives us an advantage to create user defined formats and manipulate the display as per our requirements. Here also we are taking an example of a question and we will look into the scenario where we would be creating our own user defined formats . Q1) Create the below mentioned dataset voter: Code: /*Part1*/ proc format; value age 0-30 = 'Between 0 and 31' 31-50 = 'between 31 and 50' 51-70 = 'between 51 and 70' 71-High = 'greater than 71'; value $party N = 'National Democratic alliance' U = 'United Progressive Alliance' ; value $hello 1 = 'strongly disagree' 2 = 'disagree' 3 = 'no opinion' 4 = 'agree' 5 = 'strongly agree' ; /*part2*/ data voter; input Age Party : $1.(Ques1-Ques4)($1.+1); format Age age. party $party. Ques1-Ques4 $hello.; label Ques1 = 'prime minister is doing a good job' Q...

Blog 2:Importing and Exporting excel File in SAS

Image
Welcome back to blog 2. Today's area of discussion is to import and export the excel file. Use proc import to convert the  spreadsheet drugtest. Use proc print to list down the observations in this dataset Code: The main aim of this programme for import and export the excel */ /*Question1*/ 1)proc import 2)out= work.drugtest 3)datafile = 'C:\Users\Elcot\Desktop\SAS\neha sas cody book\Practice set 4\drugtest.xls' 4)dbms=xls 5)replace; 6)sheet = "sheet1"; 7)getnames = yes; 8)run; 9)proc print data = drugtest; 10)run; Solution/Explanation: 1) proc import is the procedure to import the file 2) out states the destination where the file would be saved here it is in work library and the data set is named drugtest. 3)datafile states the path where the file is saved which is to be imported 4) dbms refers to the format of the file 5) replace overwrites an already existing data set 6)sheet refers to the sheet name 7)getnames refers to the columns names ...