Assuming you want to see the results in a print view, you can do so using the PROC PRINT procedure and the rest of the code will remain the same.
DATA Employee_Info 입력 Emp_ID Emp_Name $ Emp_Vertical $ datalines 101 Mak SQL 102 Rama SAS 103 Priya Java 104 Karthik Excel 105 Mandeep SAS Run PROC PRINT DATA = Employee_Info Run The image below shows the output of the above code.
We have just created a data set and understood how the PRINT procedure works. Now let's take the above data set and use it for further programming. Let's say we want to add the employee's joining date to the data set. So we create a variable called DOJ and give it as input and print the result.
DATA Employee_Info input Emp_ID Emp_Name $ Emp_Vertical $ DOJ datalines 101 Mak SQL 18/08/2013102 Rama SAS 25/06/2015103 Priya Java 21/02/2010104 Karthik Excel 19/05/2007105 Mandeep SAS 11/09/2016 PROC PRINT DATA = Employee_Info 실행 실행 The image below shows the output of the above code. You can see that the variable turkey phone number material is created, but the DOJ value is not printed. Instead, you can see that a dot has replaced the date value.
Why did this happen? Well, the DOJ variable does not have the suffix '$'. That means, by default, SAS reads it as a numeric variable. However, the data you entered has the special character '/', so it is not purely numeric data, and therefore does not print the result. If you check the log window, you will see an error message saying 'Invalid data for variable DOJ'.
Now how do we solve this problem? One way to solve this is to use the suffix '$' on the DOJ variable. We can convert the DOJ variable to a character and print the date value. Let's change the code and see the output.
The image below shows the output of the code mentioned above
-
- Posts: 28
- Joined: Tue Dec 03, 2024 5:11 am