159.COMPREHENSIVE ANALYSIS OF ENDANGERED SPECIES MONITORING DATASET USING SAS PROCEDURES: PROC CONTENTS | PROC MEANS | PROC FREQ | PROC SORT | PROC PRINT | PROC FORMAT | PROC TRANSPOSE | PROC EXPORT
- Get link
- X
- Other Apps
COMPREHENSIVE ANALYSIS OF ENDANGERED SPECIES MONITORING DATASET USING SAS PROCEDURES: PROC CONTENTS | PROC MEANS | PROC FREQ | PROC SORT | PROC PRINT | PROC FORMAT | PROC TRANSPOSE | PROC EXPORT
/*Creating a unique dataset centered around wildlife conservation*/
Dataset Overview
/*This dataset aims to track endangered species across different national parks,
providing insights into their population dynamics and conservation statuses.
The key variables include:*/
Species_ID: Unique identifier for each species.
Species_Name: Common name of the species.
Scientific_Name: Scientific (Latin) name.
Conservation_Status: Status such as 'Critically Endangered', 'Endangered', 'Vulnerable', etc.
Population_Count: Estimated number of individuals in the park.
Park_Name: Name of the national park.
Region: Geographical region where the park is located.
Last_Observed: Date when the species was last observed.
1. Creating the Dataset
data endangered_species;
infile datalines dsd truncover;
input Species_ID :$5.
Species_Name :$30.
Scientific_Name :$40.
Conservation_Status :$20.
Population_Count
Park_Name :$40.
Region :$30.
Last_Observed :date9.;
format Last_Observed date9.;
datalines;
SP001,"Bengal Tiger","Panthera tigris tigris","Endangered",25,"Sundarbans National Park","Eastern India",15MAR2025
SP002,"Asiatic Elephant","Elephas maximus","Vulnerable",50,"Kaziranga National Park","North-East India",20FEB2025
SP003,"Snow Leopard","Panthera uncia","Vulnerable",12,"Hemis National Park","Northern India",10JAN2025
SP004,"Indian Rhinoceros","Rhinoceros unicornis","Vulnerable",35,"Manas National Park","North-East India",05MAR2025
SP005,"Red Panda","Ailurus fulgens","Endangered",20,"Singalila National Park","Eastern India",28FEB2025
;
run;
proc print;run;
Output:
Obs | Species_ID | Species_Name | Scientific_Name | Conservation_Status | Population_Count | Park_Name | Region | Last_Observed |
---|---|---|---|---|---|---|---|---|
1 | SP001 | Bengal Tiger | Panthera tigris tigris | Endangered | 25 | Sundarbans National Park | Eastern India | 15MAR2025 |
2 | SP002 | Asiatic Elephant | Elephas maximus | Vulnerable | 50 | Kaziranga National Park | North-East India | 20FEB2025 |
3 | SP003 | Snow Leopard | Panthera uncia | Vulnerable | 12 | Hemis National Park | Northern India | 10JAN2025 |
4 | SP004 | Indian Rhinoceros | Rhinoceros unicornis | Vulnerable | 35 | Manas National Park | North-East India | 05MAR2025 |
5 | SP005 | Red Panda | Ailurus fulgens | Endangered | 20 | Singalila National Park | Eastern India | 28FEB2025 |
2.Viewing Dataset Contents
proc contents data=endangered_species;
run;
/*This procedure provides metadata about the dataset, including variable types and lengths.*/
Output:
Data Set Name | WORK.ENDANGERED_SPECIES | Observations | 5 |
---|---|---|---|
Member Type | DATA | Variables | 8 |
Engine | V9 | Indexes | 0 |
Created | 14/09/2015 00:06:05 | Observation Length | 184 |
Last Modified | 14/09/2015 00:06:05 | Deleted Observations | 0 |
Protection | Compressed | NO | |
Data Set Type | Sorted | NO | |
Label | |||
Data Representation | WINDOWS_64 | ||
Encoding | wlatin1 Western (Windows) |
Engine/Host Dependent Information | |
---|---|
Data Set Page Size | 65536 |
Number of Data Set Pages | 1 |
First Data Page | 1 |
Max Obs per Page | 355 |
Obs in First Data Page | 5 |
Number of Data Set Repairs | 0 |
ExtendObsCounter | YES |
Filename | C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD3236_DESKTOP-QFAA4KV_\endangered_species.sas7bdat |
Release Created | 9.0401M2 |
Host Created | X64_8HOME |
Alphabetic List of Variables and Attributes | ||||
---|---|---|---|---|
# | Variable | Type | Len | Format |
4 | Conservation_Status | Char | 20 | |
8 | Last_Observed | Num | 8 | DATE9. |
6 | Park_Name | Char | 40 | |
5 | Population_Count | Num | 8 | |
7 | Region | Char | 30 | |
3 | Scientific_Name | Char | 40 | |
1 | Species_ID | Char | 5 | |
2 | Species_Name | Char | 30 |
3.Descriptive Statistics
proc means data=endangered_species n mean min max;
var Population_Count;
run;
/*This computes the number of observations, mean, minimum, and maximum of the population counts.*/
Output:
Analysis Variable : Population_Count | |||
---|---|---|---|
N | Mean | Minimum | Maximum |
5 | 28.4000000 | 12.0000000 | 50.0000000 |
4.Frequency Distribution
proc freq data=endangered_species;
tables Conservation_Status;
run;
/*This shows the frequency of each conservation status category.*/
Output:
Conservation_Status | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
Endangered | 2 | 40.00 | 2 | 40.00 |
Vulnerable | 3 | 60.00 | 5 | 100.00 |
5.Sorting the Dataset
proc sort data=endangered_species out=sorted_species;
by descending Population_Count;
run;
proc print;run;
/*This sorts the species by their population count in descending order.*/
Output:
Obs | Species_ID | Species_Name | Scientific_Name | Conservation_Status | Population_Count | Park_Name | Region | Last_Observed |
---|---|---|---|---|---|---|---|---|
1 | SP002 | Asiatic Elephant | Elephas maximus | Vulnerable | 50 | Kaziranga National Park | North-East India | 20FEB2025 |
2 | SP004 | Indian Rhinoceros | Rhinoceros unicornis | Vulnerable | 35 | Manas National Park | North-East India | 05MAR2025 |
3 | SP001 | Bengal Tiger | Panthera tigris tigris | Endangered | 25 | Sundarbans National Park | Eastern India | 15MAR2025 |
4 | SP005 | Red Panda | Ailurus fulgens | Endangered | 20 | Singalila National Park | Eastern India | 28FEB2025 |
5 | SP003 | Snow Leopard | Panthera uncia | Vulnerable | 12 | Hemis National Park | Northern India | 10JAN2025 |
6.Filtering Data
data endangered_only;
set endangered_species;
where Conservation_Status = 'Endangered';
run;
proc print;run;
/*This creates a subset of species that are classified as 'Endangered'.*/
Output:
Obs | Species_ID | Species_Name | Scientific_Name | Conservation_Status | Population_Count | Park_Name | Region | Last_Observed |
---|---|---|---|---|---|---|---|---|
1 | SP001 | Bengal Tiger | Panthera tigris tigris | Endangered | 25 | Sundarbans National Park | Eastern India | 15MAR2025 |
2 | SP005 | Red Panda | Ailurus fulgens | Endangered | 20 | Singalila National Park | Eastern India | 28FEB2025 |
7.Generating Reports
proc print data=endangered_only;
title 'List of Endangered Species';
run;
/*This prints a report of endangered species.*/
Output:
List of Endangered
Species |
Obs | Species_ID | Species_Name | Scientific_Name | Conservation_Status | Population_Count | Park_Name | Region | Last_Observed |
---|---|---|---|---|---|---|---|---|
1 | SP001 | Bengal Tiger | Panthera tigris tigris | Endangered | 25 | Sundarbans National Park | Eastern India | 15MAR2025 |
2 | SP005 | Red Panda | Ailurus fulgens | Endangered | 20 | Singalila National Park | Eastern India | 28FEB2025 |
8.Creating Custom Formats
proc format;
value $status_fmt
'Critically Endangered' = 'CR'
'Endangered' = 'EN'
'Vulnerable' = 'VU';
run;
proc print data=endangered_species;
format Conservation_Status $status_fmt.;
title 'Species with Formatted Conservation Status';
run;
/*This applies custom formats to the conservation status for concise reporting.*/
Output:
Obs | Species_ID | Species_Name | Scientific_Name | Conservation_Status | Population_Count | Park_Name | Region | Last_Observed |
---|---|---|---|---|---|---|---|---|
1 | SP001 | Bengal Tiger | Panthera tigris tigris | EN | 25 | Sundarbans National Park | Eastern India | 15MAR2025 |
2 | SP002 | Asiatic Elephant | Elephas maximus | VU | 50 | Kaziranga National Park | North-East India | 20FEB2025 |
3 | SP003 | Snow Leopard | Panthera uncia | VU | 12 | Hemis National Park | Northern India | 10JAN2025 |
4 | SP004 | Indian Rhinoceros | Rhinoceros unicornis | VU | 35 | Manas National Park | North-East India | 05MAR2025 |
5 | SP005 | Red Panda | Ailurus fulgens | EN | 20 | Singalila National Park | Eastern India | 28FEB2025 |
9.Aggregating Data by Region
proc means data=endangered_species noprint;
class Region;
var Population_Count;
output out=region_summary mean=Avg_Population;
run;
proc print data=region_summary;
title 'Average Population by Region';
run;
/*This calculates the average population of species in each region.*/
Output:
Average Population by
Region |
Obs | Region | _TYPE_ | _FREQ_ | Avg_Population |
---|---|---|---|---|
1 | 0 | 5 | 28.4 | |
2 | Eastern India | 1 | 2 | 22.5 |
3 | North-East India | 1 | 2 | 42.5 |
4 | Northern India | 1 | 1 | 12.0 |
10.Transposing Data
proc transpose data=endangered_species out=transposed_species;
by Species_ID;
var Population_Count;
run;
proc print;run;
/*This transposes the population count data for each species.*/
Output:
Obs | Species_ID | _NAME_ | COL1 |
---|---|---|---|
1 | SP001 | Population_Count | 25 |
2 | SP002 | Population_Count | 50 |
3 | SP003 | Population_Count | 12 |
4 | SP004 | Population_Count | 35 |
5 | SP005 | Population_Count | 20 |
11.Exporting Data
proc export data=endangered_species
outfile='C:\Data\endangered_species.csv'
dbms=csv
replace;
run;
/*This exports the dataset to a CSV file for use in other applications.*/
/*Conclusion*/
/*This dataset demonstrates how SAS can be utilized to manage and analyze data
related to wildlife conservation. By applying various procedures,
we can gain valuable insights that aid in the protection and preservation of
endangered species.*/
- Get link
- X
- Other Apps
Comments
Post a Comment