336.Can PROC SQL and PROC SORT uncover which space inventions truly transformed global technology and innovation?
Can PROC SQL and PROC SORT uncover which space inventions truly transformed global technology and innovation?
options nocenter;
1.Creating the Dataset space_inventions
data space_inventions;
infile datalines dlm='|' missover;
input Invention_Name :$40. Inventor :$30. Year Country :$20. Usage :$60.
Success_Level :$15. Date_Assigned :yymmdd10.;
format Date_Assigned yymmdd10.;
datalines;
Artificial Satellite|Sergei Korolev|1957|USSR|Global Communication & Observation|High|1957-10-04
Space Suit|Nikolai Kamanin|1961|USSR|Astronaut Safety|High|1961-04-12
Apollo Guidance Computer|MIT Instrumentation Lab|1966|USA|Navigation System|High|1966-02-01
Space Shuttle|NASA|1981|USA|Reusable Spacecraft|Medium|1981-04-12
Hubble Telescope|NASA/ESA|1990|USA/EU|Deep-Space Observation|High|1990-04-24
Mars Rover Sojourner|NASA|1997|USA|Planetary Exploration|High|1997-07-04
International Space Station|Multiple Agencies|1998|International|Orbiting Laboratory|High|1998-11-20
Ion Propulsion Engine|NASA|1998|USA|Spacecraft Propulsion|High|1998-10-24
Reusable Rocket (Falcon 9)|SpaceX|2015|USA|Cost-Efficient Launch|High|2015-12-22
Chandrayaan Lander|ISRO|2019|India|Lunar Exploration|Medium|2019-09-07
Solar Sail Spacecraft|JAXA|2010|Japan|Photon Propulsion|Medium|2010-05-21
James Webb Space Telescope|NASA/ESA/CSA|2021|International|Infrared Space Observation|High|2021-12-25
;
run;
proc print data=space_inventions;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned |
|---|---|---|---|---|---|---|---|
| 1 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | High | 1957-10-04 |
| 2 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | High | 1961-04-12 |
| 3 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | High | 1966-02-01 |
| 4 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Medium | 1981-04-12 |
| 5 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | High | 1990-04-24 |
| 6 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | High | 1997-07-04 |
| 7 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | High | 1998-11-20 |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | High | 1998-10-24 |
| 9 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | High | 2015-12-22 |
| 10 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Medium | 2019-09-07 |
| 11 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Medium | 2010-05-21 |
| 12 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | High | 2021-12-25 |
2.PROC CONTENTS (Structure Review)
proc contents data=space_inventions;
run;
OUTPUT:
The CONTENTS Procedure
| Data Set Name | WORK.SPACE_INVENTIONS | Observations | 12 |
|---|---|---|---|
| Member Type | DATA | Variables | 7 |
| Engine | V9 | Indexes | 0 |
| Created | 12/12/2025 07:30:04 | Observation Length | 184 |
| Last Modified | 12/12/2025 07:30:04 | Deleted Observations | 0 |
| Protection | Compressed | NO | |
| Data Set Type | Sorted | NO | |
| Label | |||
| Data Representation | SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64 | ||
| Encoding | utf-8 Unicode (UTF-8) |
| Engine/Host Dependent Information | |
|---|---|
| Data Set Page Size | 131072 |
| Number of Data Set Pages | 1 |
| First Data Page | 1 |
| Max Obs per Page | 711 |
| Obs in First Data Page | 12 |
| Number of Data Set Repairs | 0 |
| Filename | /saswork/SAS_work835B0001E69A_odaws01-apse1-2.oda.sas.com/SAS_workE8080001E69A_odaws01-apse1-2.oda.sas.com/space_inventions.sas7bdat |
| Release Created | 9.0401M8 |
| Host Created | Linux |
| Inode Number | 201394094 |
| Access Permission | rw-r--r-- |
| Owner Name | u63247146 |
| File Size | 256KB |
| File Size (bytes) | 262144 |
| Alphabetic List of Variables and Attributes | ||||
|---|---|---|---|---|
| # | Variable | Type | Len | Format |
| 4 | Country | Char | 20 | |
| 7 | Date_Assigned | Num | 8 | YYMMDD10. |
| 1 | Invention_Name | Char | 40 | |
| 2 | Inventor | Char | 30 | |
| 6 | Success_Level | Char | 15 | |
| 5 | Usage | Char | 60 | |
| 3 | Year | Num | 8 | |
3.PROC SQL for Data Exploration
proc sql;
create table inventions_sql as
select Invention_Name,Inventor,Year,Country,Usage,Success_Level,Date_Assigned,
intck('year', Date_Assigned, today()) as Years_Since_Invention,
intnx('year', Date_Assigned, 10, 'same') as Date_10Years_After format=yymmdd10.
from space_inventions
order by Year;
quit;
proc print data=inventions_sql;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned | Years_Since_Invention | Date_10Years_After |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | High | 1957-10-04 | 68 | 1967-10-04 |
| 2 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | High | 1961-04-12 | 64 | 1971-04-12 |
| 3 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | High | 1966-02-01 | 59 | 1976-02-01 |
| 4 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Medium | 1981-04-12 | 44 | 1991-04-12 |
| 5 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | High | 1990-04-24 | 35 | 2000-04-24 |
| 6 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | High | 1997-07-04 | 28 | 2007-07-04 |
| 7 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | High | 1998-11-20 | 27 | 2008-11-20 |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | High | 1998-10-24 | 27 | 2008-10-24 |
| 9 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Medium | 2010-05-21 | 15 | 2020-05-21 |
| 10 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | High | 2015-12-22 | 10 | 2025-12-22 |
| 11 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Medium | 2019-09-07 | 6 | 2029-09-07 |
| 12 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | High | 2021-12-25 | 4 | 2031-12-25 |
4.PROC FORMAT for Categorizing Success Level
proc format;
value $successfmt
'High' = 'Highly Successful'
'Medium' = 'Moderately Successful'
'Low' = 'Less Impactful';
run;
LOG:
proc print data=space_inventions;
format Success_Level $successfmt.;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned |
|---|---|---|---|---|---|---|---|
| 1 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | Highly Successful | 1957-10-04 |
| 2 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | Highly Successful | 1961-04-12 |
| 3 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | Highly Successful | 1966-02-01 |
| 4 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Moderately Successful | 1981-04-12 |
| 5 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | Highly Successful | 1990-04-24 |
| 6 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | Highly Successful | 1997-07-04 |
| 7 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | Highly Successful | 1998-11-20 |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | Highly Successful | 1998-10-24 |
| 9 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | Highly Successful | 2015-12-22 |
| 10 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Moderately Successful | 2019-09-07 |
| 11 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Moderately Successful | 2010-05-21 |
| 12 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | Highly Successful | 2021-12-25 |
5.Macro for Importance Grouping
%macro importance_group(level);
%sysfunc(ifc(%upcase(&level)=HIGH,Important,
%sysfunc(ifc(%upcase(&level)=MEDIUM,Moderate,Low))))
%mend;
data inventions_with_group;
set space_inventions;
length Importance_Group $20;
Importance_Group = resolve('%importance_group(' || trim(Success_Level) || ')');
run;
proc print data=inventions_with_group;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned | Importance_Group |
|---|---|---|---|---|---|---|---|---|
| 1 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | High | 1957-10-04 | Important |
| 2 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | High | 1961-04-12 | Important |
| 3 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | High | 1966-02-01 | Important |
| 4 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Medium | 1981-04-12 | Moderate |
| 5 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | High | 1990-04-24 | Important |
| 6 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | High | 1997-07-04 | Important |
| 7 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | High | 1998-11-20 | Important |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | High | 1998-10-24 | Important |
| 9 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | High | 2015-12-22 | Important |
| 10 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Medium | 2019-09-07 | Moderate |
| 11 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Medium | 2010-05-21 | Moderate |
| 12 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | High | 2021-12-25 | Important |
6.Using PROC MEANS for Year Statistics - I
proc means data=space_inventions mean min max n;
var Year;
run;
OUTPUT:
The MEANS Procedure
| Analysis Variable : Year | |||
|---|---|---|---|
| Mean | Minimum | Maximum | N |
| 1992.75 | 1957.00 | 2021.00 | 12 |
7.Using PROC FREQ for Distribution Analysis
proc freq data=space_inventions;
tables Country Success_Level;
run;
OUTPUT:
The FREQ Procedure
| Country | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
|---|---|---|---|---|
| India | 1 | 8.33 | 1 | 8.33 |
| International | 2 | 16.67 | 3 | 25.00 |
| Japan | 1 | 8.33 | 4 | 33.33 |
| USA | 5 | 41.67 | 9 | 75.00 |
| USA/EU | 1 | 8.33 | 10 | 83.33 |
| USSR | 2 | 16.67 | 12 | 100.00 |
| Success_Level | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
|---|---|---|---|---|
| High | 9 | 75.00 | 9 | 75.00 |
| Medium | 3 | 25.00 | 12 | 100.00 |
8.PROC SORT + PRINT
proc sort data=space_inventions out=inventions_sorted;
by Country Year;
run;
proc print data=inventions_sorted;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned |
|---|---|---|---|---|---|---|---|
| 1 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Medium | 2019-09-07 |
| 2 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | High | 1998-11-20 |
| 3 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | High | 2021-12-25 |
| 4 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Medium | 2010-05-21 |
| 5 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | High | 1966-02-01 |
| 6 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Medium | 1981-04-12 |
| 7 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | High | 1997-07-04 |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | High | 1998-10-24 |
| 9 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | High | 2015-12-22 |
| 10 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | High | 1990-04-24 |
| 11 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | High | 1957-10-04 |
| 12 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | High | 1961-04-12 |
9.Date Format Demonstrations
data date_examples;
set space_inventions;
/* Extract Year, Month, Day from Date_Assigned */
Year_Extract = year(Date_Assigned);
Month_Extract = month(Date_Assigned);
Day_Extract = day(Date_Assigned);
/* Add 30 Days */
Date_Plus30 = intnx('day', Date_Assigned, 30);
/* Compare Years */
Years_Diff = intck('year', Date_Assigned, today());
/* Use MDY Function */
Recreated_Date = mdy(month(Date_Assigned), day(Date_Assigned), Year);
format Date_Plus30 Recreated_Date yymmdd10.;
run;
proc print data=date_examples;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Year | Country | Usage | Success_Level | Date_Assigned | Year_Extract | Month_Extract | Day_Extract | Date_Plus30 | Years_Diff | Recreated_Date |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Artificial Satellite | Sergei Korolev | 1957 | USSR | Global Communication & Observation | High | 1957-10-04 | 1957 | 10 | 4 | 1957-11-03 | 68 | 1957-10-04 |
| 2 | Space Suit | Nikolai Kamanin | 1961 | USSR | Astronaut Safety | High | 1961-04-12 | 1961 | 4 | 12 | 1961-05-12 | 64 | 1961-04-12 |
| 3 | Apollo Guidance Computer | MIT Instrumentation Lab | 1966 | USA | Navigation System | High | 1966-02-01 | 1966 | 2 | 1 | 1966-03-03 | 59 | 1966-02-01 |
| 4 | Space Shuttle | NASA | 1981 | USA | Reusable Spacecraft | Medium | 1981-04-12 | 1981 | 4 | 12 | 1981-05-12 | 44 | 1981-04-12 |
| 5 | Hubble Telescope | NASA/ESA | 1990 | USA/EU | Deep-Space Observation | High | 1990-04-24 | 1990 | 4 | 24 | 1990-05-24 | 35 | 1990-04-24 |
| 6 | Mars Rover Sojourner | NASA | 1997 | USA | Planetary Exploration | High | 1997-07-04 | 1997 | 7 | 4 | 1997-08-03 | 28 | 1997-07-04 |
| 7 | International Space Station | Multiple Agencies | 1998 | International | Orbiting Laboratory | High | 1998-11-20 | 1998 | 11 | 20 | 1998-12-20 | 27 | 1998-11-20 |
| 8 | Ion Propulsion Engine | NASA | 1998 | USA | Spacecraft Propulsion | High | 1998-10-24 | 1998 | 10 | 24 | 1998-11-23 | 27 | 1998-10-24 |
| 9 | Reusable Rocket (Falcon 9) | SpaceX | 2015 | USA | Cost-Efficient Launch | High | 2015-12-22 | 2015 | 12 | 22 | 2016-01-21 | 10 | 2015-12-22 |
| 10 | Chandrayaan Lander | ISRO | 2019 | India | Lunar Exploration | Medium | 2019-09-07 | 2019 | 9 | 7 | 2019-10-07 | 6 | 2019-09-07 |
| 11 | Solar Sail Spacecraft | JAXA | 2010 | Japan | Photon Propulsion | Medium | 2010-05-21 | 2010 | 5 | 21 | 2010-06-20 | 15 | 2010-05-21 |
| 12 | James Webb Space Telescope | NASA/ESA/CSA | 2021 | International | Infrared Space Observation | High | 2021-12-25 | 2021 | 12 | 25 | 2022-01-24 | 4 | 2021-12-25 |
10.Additional PROC Procedures to Demonstrate Complexity PROC UNIVARIATE
proc univariate data=space_inventions;
var Year;
run;
OUTPUT:
The UNIVARIATE Procedure
Variable: Year
| Moments | |||
|---|---|---|---|
| N | 12 | Sum Weights | 12 |
| Mean | 1992.75 | Sum Observations | 23913 |
| Std Deviation | 22.361188 | Variance | 500.022727 |
| Skewness | -0.4032807 | Kurtosis | -1.1165758 |
| Uncorrected SS | 47658131 | Corrected SS | 5500.25 |
| Coeff Variation | 1.12212711 | Std Error Mean | 6.45511895 |
| Basic Statistical Measures | |||
|---|---|---|---|
| Location | Variability | ||
| Mean | 1992.750 | Std Deviation | 22.36119 |
| Median | 1997.500 | Variance | 500.02273 |
| Mode | 1998.000 | Range | 64.00000 |
| Interquartile Range | 39.00000 | ||
| Tests for Location: Mu0=0 | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Student's t | t | 308.7085 | Pr > |t| | <.0001 |
| Sign | M | 6 | Pr >= |M| | 0.0005 |
| Signed Rank | S | 39 | Pr >= |S| | 0.0005 |
| Quantiles (Definition 5) | |
|---|---|
| Level | Quantile |
| 100% Max | 2021.0 |
| 99% | 2021.0 |
| 95% | 2021.0 |
| 90% | 2019.0 |
| 75% Q3 | 2012.5 |
| 50% Median | 1997.5 |
| 25% Q1 | 1973.5 |
| 10% | 1961.0 |
| 5% | 1957.0 |
| 1% | 1957.0 |
| 0% Min | 1957.0 |
| Extreme Observations | |||
|---|---|---|---|
| Lowest | Highest | ||
| Value | Obs | Value | Obs |
| 1957 | 1 | 1998 | 8 |
| 1961 | 2 | 2010 | 11 |
| 1966 | 3 | 2015 | 9 |
| 1981 | 4 | 2019 | 10 |
| 1990 | 5 | 2021 | 12 |
11.Using PROC MEANS for Year Statistics - II
proc means data=space_inventions;
var Year Usage;
run;
/* Note: In practice above there is an Invalid in this code Find it,Correct it and Use it /*
14. Average of Steps_Per_Day
proc avg data=work.fitness_final;
var Steps_Per_Day;
run;
proc means data=work.fitness_final mean;
var Steps_Per_Day;
run;
OUTPUT:
| Obs | _TYPE_ | _FREQ_ | Avg_Steps |
|---|---|---|---|
| 1 | 0 | 12 | 7666.67 |
PROC AVG does NOT exist in SAS.
/* Note: In practice above there is an Invalid in this code Find it,Correct it and Use it /*
Comments
Post a Comment