How to use PROC DELETE in SAS with an example? 2

How to use PROC DELETE in SAS with an example?

PROC DELETE is a procedure in SAS that allows users to delete observations or variables from a data set. To use PROC DELETE, first specify the data set to be modified and then use the DELETE statement to specify the observations or variables to be deleted. The following is an example of using PROC DELETE to delete all observations from the data set “sales_data” where the variable “product_type” equals “Furniture”:

PROC DELETE DATA = sales_data;
DELETE WHERE product_type = ‘Furniture’;
RUN;

This will result in all furniture sales data being removed from the “sales_data” data set. It is important to note that PROC DELETE permanently deletes the specified observations or variables from the data set, so it is recommended to create a backup of the data set before using this procedure.

Use PROC DELETE in SAS (With Example)


You can use the PROC DELETE statement in SAS to delete specific files in folders.

There are two common ways to use this statement in practice:

Method 1: Use PROC DELETE to Delete One Specific Dataset

/*define path to folder*/
libname folder1 '/home/u13181/folder1/';

/*delete dataset called data1 in folder called folder1*/
proc deletedata=folder1.data1;
run;

Method 2: Use PROC DELETE to Delete Multiple Datasets

/*define path to folder*/
libname folder1 '/home/u13181/folder1/';

/*delete datasets called data2 and data3 in folder called folder1*/
proc deletedata=folder1.data2 folder1.data3;
run;

The following examples show how to use PROC DELETE in practice with the following folder in SAS called folder1 that contains three datasets:

Example 1: Use PROC DELETE to Delete One Specific Dataset

We can use the following syntax with PROC DELETE to delete the dataset called data1 from the folder called folder1:

/*define path to folder*/
libname folder1 '/home/u13181/folder1/';

/*delete dataset called data1 in folder called folder1*/
proc deletedata=folder1.data1;
run;

When we navigate back to folder1 we can see that the dataset called data1 has been deleted from the folder:

Example 2: Use PROC DELETE to Delete Multiple Datasets

We can use the following syntax with PROC DELETE to delete the datasets called data2 and data3 from the folder called folder1:

/*define path to folder*/
libname folder1 '/home/u13181/folder1/';

/*delete datasets called data2 and data3 in folder called folder1*/
proc deletedata=folder1.data2 folder1.data3;
run;

When we navigate back to folder1 we can see that both datasets have been deleted from the folder:

Note: You can find the complete documentation for the PROC DELETE statement in SAS .

The following tutorials explain how to perform other common tasks in SAS:

Cite this article

stats writer (2024). How to use PROC DELETE in SAS with an example?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-use-proc-delete-in-sas-with-an-example/

stats writer. "How to use PROC DELETE in SAS with an example?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-to-use-proc-delete-in-sas-with-an-example/.

stats writer. "How to use PROC DELETE in SAS with an example?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-to-use-proc-delete-in-sas-with-an-example/.

stats writer (2024) 'How to use PROC DELETE in SAS with an example?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-use-proc-delete-in-sas-with-an-example/.

[1] stats writer, "How to use PROC DELETE in SAS with an example?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How to use PROC DELETE in SAS with an example?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top