337.ANALYTICAL PROGRAM FOR SPACE INVENTIONS USING PROC SQL | PROC MEANS | PROC FREQ | PROC FORMAT | PROC SORT | PROC PRINT | MACRO PROCESSING WITH INTCK | INTNX DATE FUNCTIONS
ANALYTICAL PROGRAM FOR SPACE INVENTIONS USING PROC SQL | PROC MEANS | PROC FREQ | PROC FORMAT | PROC SORT | PROC PRINT | MACRO PROCESSING WITH INTCK | INTNX DATE FUNCTIONS
options nocenter;
1.PROC FORMAT FOR SUCCESS LEVEL
proc format;
value $successfmt
"High" = "Highly Successful"
"Medium" = "Moderately Successful"
"Low" = "Low Success"
other = "Unknown";
run;
LOG:
2.MACRO FOR IMPORTANCE GROUPING
%macro importance_macro(var=, outvar=);
if strip(&var) = "High" then &outvar = "Critical";
else if strip(&var) = "Medium" then &outvar = "Significant";
else &outvar = "Minor";
%mend importance_macro;
3.CREATE DATASET: SPACE INVENTIONS
data space_inventions;
length Invention_Name $40 Inventor $40 Country $30 Usage $50 Success_Level $10;
informat Invent_Date Review_Date date9.;
format Invent_Date Review_Date date9.;
input Invention_Name :$40. Inventor:$40. Year Country:$30. Usage:$50.
Success_Level:$10. Invent_Date:date9. Review_Date:date9.;
datalines;
Satcom ArthurCClarke 1964 UK Communication High 01JAN1964 01FEB1964
LunarModule NASA 1969 USA Landing Medium 15JUL1969 10AUG1969
GPS Pentagon 1978 USA Navigation High 01JAN1978 15JAN1978
SpaceShuttle NASA 1981 USA Transport High 12APR1981 20APR1981
MarsRover JPL 1997 USA Exploration High 04JUL1997 15JUL1997
HubbleTelescope ESA 1990 EU Observation High 24APR1990 01MAY1990
Sputnik Satellite 1957 USSR Communication Medium 04OCT1957 20OCT1957
ISS NASA_Roscosmos 1998 International Research High 20NOV1998 10DEC1998
CryogenicEngine ISRO 2014 India Propulsion High 05JAN2014 25JAN2014
ReusableRocket SpaceX 2015 USA Transport High 22DEC2015 10JAN2016
ChandrayaanOrbiter ISRO 2008 India Exploration Medium 22OCT2008 15NOV2008
SolarSail JAXA 2010 Japan Propulsion Low 21MAY2010 18JUN2010
;
run;
proc print data=space_inventions;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Country | Usage | Success_Level | Invent_Date | Review_Date | Year |
|---|---|---|---|---|---|---|---|---|
| 1 | Satcom | ArthurCClarke | UK | Communication | High | 01JAN1964 | 01FEB1964 | 1964 |
| 2 | LunarModule | NASA | USA | Landing | Medium | 15JUL1969 | 10AUG1969 | 1969 |
| 3 | GPS | Pentagon | USA | Navigation | High | 01JAN1978 | 15JAN1978 | 1978 |
| 4 | SpaceShuttle | NASA | USA | Transport | High | 12APR1981 | 20APR1981 | 1981 |
| 5 | MarsRover | JPL | USA | Exploration | High | 04JUL1997 | 15JUL1997 | 1997 |
| 6 | HubbleTelescope | ESA | EU | Observation | High | 24APR1990 | 01MAY1990 | 1990 |
| 7 | Sputnik | Satellite | USSR | Communication | Medium | 04OCT1957 | 20OCT1957 | 1957 |
| 8 | ISS | NASA_Roscosmos | International | Research | High | 20NOV1998 | 10DEC1998 | 1998 |
| 9 | CryogenicEngine | ISRO | India | Propulsion | High | 05JAN2014 | 25JAN2014 | 2014 |
| 10 | ReusableRocket | SpaceX | USA | Transport | High | 22DEC2015 | 10JAN2016 | 2015 |
| 11 | ChandrayaanOrbiter | ISRO | India | Exploration | Medium | 22OCT2008 | 15NOV2008 | 2008 |
| 12 | SolarSail | JAXA | Japan | Propulsion | Low | 21MAY2010 | 18JUN2010 | 2010 |
4.ADD IMPORTANCE GROUP USING MACRO
data inventions_with_importance;
set space_inventions;
length Importance_Group $20;
%importance_macro(var=Success_Level, outvar=Importance_Group);
run;
proc print data=inventions_with_importance;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Country | Usage | Success_Level | Invent_Date | Review_Date | Year | Importance_Group |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Satcom | ArthurCClarke | UK | Communication | High | 01JAN1964 | 01FEB1964 | 1964 | Critical |
| 2 | LunarModule | NASA | USA | Landing | Medium | 15JUL1969 | 10AUG1969 | 1969 | Significant |
| 3 | GPS | Pentagon | USA | Navigation | High | 01JAN1978 | 15JAN1978 | 1978 | Critical |
| 4 | SpaceShuttle | NASA | USA | Transport | High | 12APR1981 | 20APR1981 | 1981 | Critical |
| 5 | MarsRover | JPL | USA | Exploration | High | 04JUL1997 | 15JUL1997 | 1997 | Critical |
| 6 | HubbleTelescope | ESA | EU | Observation | High | 24APR1990 | 01MAY1990 | 1990 | Critical |
| 7 | Sputnik | Satellite | USSR | Communication | Medium | 04OCT1957 | 20OCT1957 | 1957 | Significant |
| 8 | ISS | NASA_Roscosmos | International | Research | High | 20NOV1998 | 10DEC1998 | 1998 | Critical |
| 9 | CryogenicEngine | ISRO | India | Propulsion | High | 05JAN2014 | 25JAN2014 | 2014 | Critical |
| 10 | ReusableRocket | SpaceX | USA | Transport | High | 22DEC2015 | 10JAN2016 | 2015 | Critical |
| 11 | ChandrayaanOrbiter | ISRO | India | Exploration | Medium | 22OCT2008 | 15NOV2008 | 2008 | Significant |
| 12 | SolarSail | JAXA | Japan | Propulsion | Low | 21MAY2010 | 18JUN2010 | 2010 | Minor |
5.PROC SQL EXAMPLE
proc sql;
create table invention_summary as
select Country,
count(*) as Total_Inventions,
mean(Year) as Avg_Year
from space_inventions
group by Country;
quit;
proc print data=invention_summary;
run;
OUTPUT:
| Obs | Country | Total_Inventions | Avg_Year |
|---|---|---|---|
| 1 | EU | 1 | 1990 |
| 2 | India | 2 | 2011 |
| 3 | International | 1 | 1998 |
| 4 | Japan | 1 | 2010 |
| 5 | UK | 1 | 1964 |
| 6 | USA | 5 | 1988 |
| 7 | USSR | 1 | 1957 |
6.USING INTCK & INTNX FOR DATE INTERVAL ANALYSIS
data date_analysis;
set space_inventions;
Days_Between = intck('day', Invent_Date, Review_Date);
Next_Review = intnx('month', Review_Date, 6, 'same');
format Next_Review date9.;
run;
proc print data=date_analysis;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Country | Usage | Success_Level | Invent_Date | Review_Date | Year | Days_Between | Next_Review |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Satcom | ArthurCClarke | UK | Communication | High | 01JAN1964 | 01FEB1964 | 1964 | 31 | 01AUG1964 |
| 2 | LunarModule | NASA | USA | Landing | Medium | 15JUL1969 | 10AUG1969 | 1969 | 26 | 10FEB1970 |
| 3 | GPS | Pentagon | USA | Navigation | High | 01JAN1978 | 15JAN1978 | 1978 | 14 | 15JUL1978 |
| 4 | SpaceShuttle | NASA | USA | Transport | High | 12APR1981 | 20APR1981 | 1981 | 8 | 20OCT1981 |
| 5 | MarsRover | JPL | USA | Exploration | High | 04JUL1997 | 15JUL1997 | 1997 | 11 | 15JAN1998 |
| 6 | HubbleTelescope | ESA | EU | Observation | High | 24APR1990 | 01MAY1990 | 1990 | 7 | 01NOV1990 |
| 7 | Sputnik | Satellite | USSR | Communication | Medium | 04OCT1957 | 20OCT1957 | 1957 | 16 | 20APR1958 |
| 8 | ISS | NASA_Roscosmos | International | Research | High | 20NOV1998 | 10DEC1998 | 1998 | 20 | 10JUN1999 |
| 9 | CryogenicEngine | ISRO | India | Propulsion | High | 05JAN2014 | 25JAN2014 | 2014 | 20 | 25JUL2014 |
| 10 | ReusableRocket | SpaceX | USA | Transport | High | 22DEC2015 | 10JAN2016 | 2015 | 19 | 10JUL2016 |
| 11 | ChandrayaanOrbiter | ISRO | India | Exploration | Medium | 22OCT2008 | 15NOV2008 | 2008 | 24 | 15MAY2009 |
| 12 | SolarSail | JAXA | Japan | Propulsion | Low | 21MAY2010 | 18JUN2010 | 2010 | 28 | 18DEC2010 |
7.PROC MEANS
proc means data=date_analysis n mean min max;
var Days_Between Year;
run;
OUTPUT:
The MEANS Procedure
| Variable | N | Mean | Minimum | Maximum |
|---|---|---|---|---|
Days_Between Year | 12 12 | 18.6666667 1990.08 | 7.0000000 1957.00 | 31.0000000 2015.00 |
8.PROC FREQ
proc freq data=inventions_with_importance;
tables Country Success_Level Importance_Group;
format Success_Level $successfmt.;
run;
OUTPUT:
The FREQ Procedure
| Country | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
|---|---|---|---|---|
| EU | 1 | 8.33 | 1 | 8.33 |
| India | 2 | 16.67 | 3 | 25.00 |
| International | 1 | 8.33 | 4 | 33.33 |
| Japan | 1 | 8.33 | 5 | 41.67 |
| UK | 1 | 8.33 | 6 | 50.00 |
| USA | 5 | 41.67 | 11 | 91.67 |
| USSR | 1 | 8.33 | 12 | 100.00 |
| Success_Level | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
|---|---|---|---|---|
| Highly Successful | 8 | 66.67 | 8 | 66.67 |
| Low Success | 1 | 8.33 | 9 | 75.00 |
| Moderately Successful | 3 | 25.00 | 12 | 100.00 |
| Importance_Group | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
|---|---|---|---|---|
| Critical | 8 | 66.67 | 8 | 66.67 |
| Minor | 1 | 8.33 | 9 | 75.00 |
| Significant | 3 | 25.00 | 12 | 100.00 |
9.ADDITIONAL PROC SORT & PRINT |
proc sort data=inventions_with_importance out=sorted_inventions;
by Country Year;
run;
proc print data=sorted_inventions;
run;
OUTPUT:
| Obs | Invention_Name | Inventor | Country | Usage | Success_Level | Invent_Date | Review_Date | Year | Importance_Group |
|---|---|---|---|---|---|---|---|---|---|
| 1 | HubbleTelescope | ESA | EU | Observation | High | 24APR1990 | 01MAY1990 | 1990 | Critical |
| 2 | ChandrayaanOrbiter | ISRO | India | Exploration | Medium | 22OCT2008 | 15NOV2008 | 2008 | Significant |
| 3 | CryogenicEngine | ISRO | India | Propulsion | High | 05JAN2014 | 25JAN2014 | 2014 | Critical |
| 4 | ISS | NASA_Roscosmos | International | Research | High | 20NOV1998 | 10DEC1998 | 1998 | Critical |
| 5 | SolarSail | JAXA | Japan | Propulsion | Low | 21MAY2010 | 18JUN2010 | 2010 | Minor |
| 6 | Satcom | ArthurCClarke | UK | Communication | High | 01JAN1964 | 01FEB1964 | 1964 | Critical |
| 7 | LunarModule | NASA | USA | Landing | Medium | 15JUL1969 | 10AUG1969 | 1969 | Significant |
| 8 | GPS | Pentagon | USA | Navigation | High | 01JAN1978 | 15JAN1978 | 1978 | Critical |
| 9 | SpaceShuttle | NASA | USA | Transport | High | 12APR1981 | 20APR1981 | 1981 | Critical |
| 10 | MarsRover | JPL | USA | Exploration | High | 04JUL1997 | 15JUL1997 | 1997 | Critical |
| 11 | ReusableRocket | SpaceX | USA | Transport | High | 22DEC2015 | 10JAN2016 | 2015 | Critical |
| 12 | Sputnik | Satellite | USSR | Communication | Medium | 04OCT1957 | 20OCT1957 | 1957 | Significant |
10.BASIC DESCRIPTIVE STATISTICS
proc mean data=space_inventions;
var Year;
run;
The MEANS Procedure
| Analysis Variable : Year | ||||
|---|---|---|---|---|
| N | Mean | Std Dev | Minimum | Maximum |
| 12 | 1990.08 | 20.1560202 | 1957.00 | 2015.00 |
/* Note: In practice above there is an Invalid in this code Find it,Correct it and Use it /*
proc means data=space_inventions;
var Year Usage;
run;
Comments
Post a Comment