IF AND THEN STATEMENT IN SAS

In this post, I will discuss about the “If and then Statements in SAS”. Here , I have created the dataset where I have mentioned emp_id in numbers as well as single character. See the below SS related to Dataset created.Now, on the above dataset I will apply If and then statement and assign numbers to single character emp_id. See the below code for the same. DATA EMP_NEW_DET;SET EMP_DET;IF EMP_ID=”A” THEN EMP_ID= “1”;ELSE IF EMP_ID=”B” THEN EMP_ID= “2”;RUN; Once you execute the above code, the below output will appear.

SUM USING GROUP BY IN SAS

In this post, I will discuss about “How to perform sum function based on particular column in SAS”. In one of my blog , I have already explained about Sorting in SAS using Employee Data. Once sorting is done based on the Emp_id, I will sum the salary the based on the emp_id. Below is the code for the same. DATA EMP_SUM_DET(drop=SALARY);SET EMP_DET;BY EMP_ID;if First.EMP_ID then TotalSalary=0;TotalSalary+SALARY;if Last.EMP_ID;run;Here, we are using If, first and last function . For each employee, we are setting the intial TotalSalary=0 . Here , another…

equivalent of sum of columns in SAS

Today, I will discuss about “How to design SAS code which is equivalent of sum of columns in database. Consider the below employee details. In order to get sum of Year-2019 and Year-2020, we need to use add (+) operator to achieve the same. See the below Query and data for the same. Here, i applied ,normal addition, sum using ISNULL function, difference using absolute(ABS) function. In order to achieve the same in SAS . Create the same Datasets . See the below Screen Shot for the same. Now, create…

features of SAS Tool

Today, I will discuss about the features of SAS. As I started my career as database developer ,hence I will share features which is similar to database commands which will help you all in migration projects. 1. Connect to any data base like Sql-server , Netezza, Oracle using connect to odbc command.2. Perform nesting of SAS scripts inside one SAS script using macro and include commands.3. Perform union all, all joins(left outer,right outer,full outer) operations in SAS using merge and set commands4. Read data from any file like csv ,pipe(|)…

equivalent of union all in SAS

Today , I will discuss about ” How to code in SAS which is equivalent of union all in Database.See the below Data set in Sql Server. See the output of union all in Sql Server Perform the same Steps for SAS as well. First, create the same data set in SAS. Below code will perform union all logic in SAS.* Tricky part here is renaming of columns , otherwise data will not look alike that of sql server. See the SAS output for the same.

equivalent of full outer join in SAS

Today, I will discuss about “How to design SAS code which is equivalent of full outer join in database”. We created the two datasets in sql-server. when we apply full outer join on above data set. In SAS, create the dataset same as TEST1 and TEST2 tables.* Always remember to sort the data. Make a habit of this in SAS. Merge the above datasets using the below code. See the final output for the same.

equivalent of inner join in SAS

Today, I will discuss about “How to design code in SAS which is equivalent to inner join in database where column name are different in both the data sets or tables in terms of database.Below is the data in two tables. Now, apply inner Join in both the tables on condition COL1=COL4 and below is the output of the same. Next step , try to first create the same dataset in SAS and then apply logic on that data to get result equivalent of inner join.Create the dataset same as…