#2 Subsets

You can think of a subset as part of a larger group or a filter of a larger group. In this tutorial we will get a subset of the Cars table located in SASHELP. More specifically I want only cars who have the origin of Asia.

SASHELP is a permanent library that contains sample data like the Cars table. The table Cars contains 428 observations or rows.

/*Print all observations/rows in the table Cars */
proc print data= sashelp.cars;
run;
sashelp.cars table
/*Create Asian Cars Data Set*/
data AsianCars;
set sashelp.cars;
where origin = 'Asia';
run;
/*Print the data from AsianCars*/
proc print data = AsianCars;
run;

Results: There were 158 observations read from the data set SASHELP.CARS

32 Observations / Rows of Asian Car Data

Now let’s make a subset of the cars table but this time we will keep only a few columns: make, model, origin, and MPG_City. We will also display every column except for the origin column when printing to the screen.

--

--

No responses yet