• No products in the cart.

SAS Programming Fundamentals

Play Video

What are the Proc Contents in SAS?

PROC CONTENTS is a SAS procedure that provides detailed information about the contents of SAS data sets. It can be used to view metadata such as the names, types, and formats of the variables in a data set, as well as the number of observations and other attributes.

To use PROC CONTENTS in SAS, you can follow these basic steps:

1. Open SAS: Open the SAS application on your computer. The application should launch with a main menu screen.
2. Open the Program Editor: To create a new program, go to File > New > Program to open the Program Editor window.
3. Write SAS code: In the Program Editor window, type the following code to use PROC CONTENTS on a data set called “mydata”:

proc contentsproc contents data=mydata;

run;

4. Run the program: To run your program, go to the Program Editor window and click the Run button (a green arrow icon). Alternatively, you can run the program by pressing the F3 key.
5. View the output: After the program has finished running, the output will appear in the Output window. In this example, the output will display information about the variables in the “mydata” data set, including their names, types, lengths, and formats.

PROC CONTENTS can also be used to extract specific pieces of information from SAS data sets, such as the number of observations, the variable labels, or the creation date. To do this, you can use options like VAR, OUT, and PRINT in the PROC CONTENTS statement.

Overall, PROC CONTENTS is a useful tool for exploring and analyzing the metadata of SAS data sets, and can help users understand the structure and content of their data.

How to create SAS Libiray?

In SAS, a library is a collection of one or more SAS data sets that are stored together in a single location. You can create a new library in SAS by following these steps:

1. Open SAS: Open the SAS application on your computer. The application should launch with a main menu screen.
2. Open the Explorer window: To create a new library, go to View > Explorer to open the Explorer window.
3. Select a folder location: In the Explorer window, select a folder location where you want to create the new library. This could be a local folder on your computer or a network location.
4. Right-click and select New Library: Right-click on the selected folder location and choose New Library from the context menu.
5. Define the library properties: In the New Library window, define the properties of the new library. This includes:
• Library name: Enter a name for the new library.
• Engine: Select the engine that you want to use for the new library. The engine determines how SAS reads and writes data in the library. Common engines include SAS, V9, and SQL.
• Physical Name: Enter the physical name of the library, which is the file path or network location where the library will be stored.
• Other options: You can also set other options for the new library, such as whether to make it the default library.
6. Click OK: Once you have defined the properties of the new library, click OK to create the library.

After you have created the new library, you can use it to store and access SAS data sets. To view the contents of the new library, go to the Explorer window and expand the library name to see the data sets it contains. You can also use the library name in your SAS code to reference data sets stored in the library. For example, to access a data set called “mydata” in the new library, you would use the following code:

data newdata;

   set mylib.mydata;

run;

In this example, “mylib” is the name of the new library you created, and “mydata” is the name of the data set within the library.

How to create simple Program in SAS?

To create a simple SAS program, you can follow these steps:

1. Open SAS: Open the SAS application on your computer. The application should launch with a main menu screen.
2. Open the Program Editor: To create a new program, go to File > New > Program to open the Program Editor window.
3. Write SAS code: In the Program Editor window, type your SAS code. For example, you can write a simple data step to create a SAS data set:

data test;

   input x y;

   datalines;

   1 2

   3 4

   5 6

   ;

run;

4. Save the program: Once you have written your SAS code, go to File > Save As to save the program. Give your program a name and choose a location to save it.
5. Run the program: To run your program, go to the Program Editor window and click the Run button (a green arrow icon). Alternatively, you can run the program by pressing the F3 key.
6. View the output: After the program has finished running, the output will appear in the Output window. In this example, the output will be a SAS data set called “test” that contains three observations and two variables (x and y).

That’s it! This is a basic example of how to create and run a simple SAS program. From here, you can build on this foundation to create more complex programs for data analysis and other tasks.

07/03/2023
Template Design ©Naidu Tutorial All rights reserved.
Chat with Us
1
We are Online
Hello ,
How we can help you ?