Wednesday, 26 November 2025

321.WORLD HISTORICAL MONUMENTS DATASET CREATION WITH DATE FORMATS | PROC SQL | PROC FREQ | PROC MEANS | PROC SGPLOT | MACRO AUTOMATION | INTNX | INTCK BASED TOURISM CATEGORIZATION AND ANALYTICAL MODELING

WORLD HISTORICAL MONUMENTS DATASET CREATION WITH DATE FORMATS | PROC SQL | PROC FREQ | PROC MEANS | PROC SGPLOT | MACRO AUTOMATION | INTNX | INTCK BASED TOURISM CATEGORIZATION AND ANALYTICAL MODELING

options nocenter nodate nonumber;

Step 1: Create a raw dataset of world historical monuments 

data work.monuments_raw;

    length Monument_Name $40 Country $20 UNESCO_Status $3 Construction_Date_Char $10;

    infile datalines dsd truncover;      

    input Monument_Name :$40. Country :$20. Visitors_per_Year Construction_Year 

          UNESCO_Status :$3.  Entry_Fee Construction_Date_Char :$10. Sample_Visit :date9.;

    format Sample_Visit date9. Construction_Date date9. Entry_Fee 8.2;

    /* ----- DATE PROTECTION LOGIC ----- */

    if Construction_Year >= 1582 then

        Construction_Date = mdy(1,1,Construction_Year);

    else

        Construction_Date = .;

datalines;

"Great Wall of China","China",10000000,0700,"Yes",40,"01JAN0700","15FEB2024"

"Colosseum","Italy",7500000,0800,"Yes",20,"01JAN0800","20APR2024"

"Statue of Liberty","USA",4300000,1886,"Yes",25,"01JAN1886","10MAR2024"

"Taj Mahal","India",9000000,1653,"Yes",50,"01JAN1653","25FEB2024"

"Machu Picchu","Peru",1500000,1450,"Yes",45,"01JAN1450","05MAY2024"

"Eiffel Tower","France",7000000,1889,"Yes",30,"01JAN1889","22APR2024"

"Angkor Wat","Cambodia",2500000,1150,"Yes",37,"01JAN1150","25MAR2024"

"Christ the Redeemer","Brazil",2000000,1931,"Yes",35,"01JAN1931","18FEB2024"

"Acropolis of Athens","Greece",2000000,0500,"Yes",20,"01JAN0500","12APR2024"

"Petra","Jordan",1200000,0300,"Yes",35,"01JAN0300","30MAR2024"

"Stonehenge","UK",1400000,2500,"Yes",28,"01JAN2500","16APR2024"

"Chichen Itza","Mexico",2300000,0600,"Yes",30,"01JAN0600","08MAR2024"

;

run;

proc print data=work.monuments_raw;

run;

OUTPUT:

ObsMonument_NameCountryUNESCO_StatusConstruction_Date_CharVisitors_per_YearConstruction_YearEntry_FeeSample_VisitConstruction_Date
1Great Wall of ChinaChinaYes01JAN07001000000070040.0015FEB2024.
2ColosseumItalyYes01JAN0800750000080020.0020APR2024.
3Statue of LibertyUSAYes01JAN18864300000188625.0010MAR202401JAN1886
4Taj MahalIndiaYes01JAN16539000000165350.0025FEB202401JAN1653
5Machu PicchuPeruYes01JAN14501500000145045.0005MAY2024.
6Eiffel TowerFranceYes01JAN18897000000188930.0022APR202401JAN1889
7Angkor WatCambodiaYes01JAN11502500000115037.0025MAR2024.
8Christ the RedeemerBrazilYes01JAN19312000000193135.0018FEB202401JAN1931
9Acropolis of AthensGreeceYes01JAN0500200000050020.0012APR2024.
10PetraJordanYes01JAN0300120000030035.0030MAR2024.
11StonehengeUKYes01JAN25001400000250028.0016APR202401JAN2500
12Chichen ItzaMexicoYes01JAN0600230000060030.0008MAR2024.


Step 2: Use PROC SQL to create an enhanced dataset 

proc sql;

    create table work.monuments_sql as

    select  Monument_Name,Country,Visitors_per_Year,Construction_Year,UNESCO_Status,

            Entry_Fee,Construction_Date,Sample_Visit,year(Sample_Visit) as Visit_Year,

            /* Age of monument at the time of Sample_Visit */

            intck('year', Construction_Date, Sample_Visit) as Age_at_Visit_Years

    from work.monuments_raw;

quit;

proc print data=work.monuments_sql;

run;

OUTPUT:

ObsMonument_NameCountryVisitors_per_YearConstruction_YearUNESCO_StatusEntry_FeeConstruction_DateSample_VisitVisit_YearAge_at_Visit_Years
1Great Wall of ChinaChina10000000700Yes40.00.15FEB20242024.
2ColosseumItaly7500000800Yes20.00.20APR20242024.
3Statue of LibertyUSA43000001886Yes25.0001JAN188610MAR20242024138
4Taj MahalIndia90000001653Yes50.0001JAN165325FEB20242024371
5Machu PicchuPeru15000001450Yes45.00.05MAY20242024.
6Eiffel TowerFrance70000001889Yes30.0001JAN188922APR20242024135
7Angkor WatCambodia25000001150Yes37.00.25MAR20242024.
8Christ the RedeemerBrazil20000001931Yes35.0001JAN193118FEB2024202493
9Acropolis of AthensGreece2000000500Yes20.00.12APR20242024.
10PetraJordan1200000300Yes35.00.30MAR20242024.
11StonehengeUK14000002500Yes28.0001JAN250016APR20242024-476
12Chichen ItzaMexico2300000600Yes30.00.08MAR20242024.


Step 3: More enhancements with INTNX and INTCK 

data work.monuments_enhanced;

    set work.monuments_sql;

    format Years_Since_Construction 8. Next_Year_Visit date9. Anniversary_500 date9.

           Years_Until_500 8.;


    /* Age from construction to today */

    Years_Since_Construction = intck('year', Construction_Date, today());


    /* Next year's sample visit date (same day and month) */

    Next_Year_Visit = intnx('year', Sample_Visit, 1, 'same');


    /* 500-year anniversary (500 years after Construction_Date) */

    Anniversary_500 = intnx('year', Construction_Date, 500, 'same');


    /* How many years from today until the 500-year anniversary */

    Years_Until_500 = intck('year', today(), Anniversary_500);

run;

proc print data=work.monuments_enhanced;

run;

OUTPUT:

ObsMonument_NameCountryVisitors_per_YearConstruction_YearUNESCO_StatusEntry_FeeConstruction_DateSample_VisitVisit_YearAge_at_Visit_YearsYears_Since_ConstructionNext_Year_VisitAnniversary_500Years_Until_500
1Great Wall of ChinaChina10000000700Yes40.00.15FEB20242024..15FEB2025..
2ColosseumItaly7500000800Yes20.00.20APR20242024..20APR2025..
3Statue of LibertyUSA43000001886Yes25.0001JAN188610MAR2024202413813910MAR202501JAN2386361
4Taj MahalIndia90000001653Yes50.0001JAN165325FEB2024202437137225FEB202501JAN2153128
5Machu PicchuPeru15000001450Yes45.00.05MAY20242024..05MAY2025..
6Eiffel TowerFrance70000001889Yes30.0001JAN188922APR2024202413513622APR202501JAN2389364
7Angkor WatCambodia25000001150Yes37.00.25MAR20242024..25MAR2025..
8Christ the RedeemerBrazil20000001931Yes35.0001JAN193118FEB20242024939418FEB202501JAN2431406
9Acropolis of AthensGreece2000000500Yes20.00.12APR20242024..12APR2025..
10PetraJordan1200000300Yes35.00.30MAR20242024..30MAR2025..
11StonehengeUK14000002500Yes28.0001JAN250016APR20242024-476-47516APR202501JAN3000975
12Chichen ItzaMexico2300000600Yes30.00.08MAR20242024..08MAR2025..


Step 4: Macro for Tourism Categorization 

%macro categorize_tourism(in=work.monuments_enhanced,

                          out=work.monuments_final,

                          high_visitors=5000000,

                          low_fee=30);


    data &out;

        set ∈

        length Tourism_Category $20;


        if Visitors_per_Year >= &high_visitors and Entry_Fee <= &low_fee then

            Tourism_Category = 'Mass Budget';

        else if Visitors_per_Year >= &high_visitors and Entry_Fee > &low_fee then

            Tourism_Category = 'Premium Mass';

        else if Visitors_per_Year < &high_visitors and Entry_Fee > &low_fee then

            Tourism_Category = 'Niche Premium';

        else

            Tourism_Category = 'Niche Budget';

    run;

proc print data=&out;

run;

%mend categorize_tourism;


%categorize_tourism();

OUTPUT:

ObsMonument_NameCountryVisitors_per_YearConstruction_YearUNESCO_StatusEntry_FeeConstruction_DateSample_VisitVisit_YearAge_at_Visit_YearsYears_Since_ConstructionNext_Year_VisitAnniversary_500Years_Until_500Tourism_Category
1Great Wall of ChinaChina10000000700Yes40.00.15FEB20242024..15FEB2025..Premium Mass
2ColosseumItaly7500000800Yes20.00.20APR20242024..20APR2025..Mass Budget
3Statue of LibertyUSA43000001886Yes25.0001JAN188610MAR2024202413813910MAR202501JAN2386361Niche Budget
4Taj MahalIndia90000001653Yes50.0001JAN165325FEB2024202437137225FEB202501JAN2153128Premium Mass
5Machu PicchuPeru15000001450Yes45.00.05MAY20242024..05MAY2025..Niche Premium
6Eiffel TowerFrance70000001889Yes30.0001JAN188922APR2024202413513622APR202501JAN2389364Mass Budget
7Angkor WatCambodia25000001150Yes37.00.25MAR20242024..25MAR2025..Niche Premium
8Christ the RedeemerBrazil20000001931Yes35.0001JAN193118FEB20242024939418FEB202501JAN2431406Niche Premium
9Acropolis of AthensGreece2000000500Yes20.00.12APR20242024..12APR2025..Niche Budget
10PetraJordan1200000300Yes35.00.30MAR20242024..30MAR2025..Niche Premium
11StonehengeUK14000002500Yes28.0001JAN250016APR20242024-476-47516APR202501JAN3000975Niche Budget
12Chichen ItzaMexico2300000600Yes30.00.08MAR20242024..08MAR2025..Niche Budget


Step 5: Frequency analysis 

proc freq data=work.monuments_final;

    tables Country UNESCO_Status Tourism_Category 

           UNESCO_Status*Tourism_Category / nocum nopercent;

run;

OUTPUT:

The FREQ Procedure

CountryFrequency
Brazil1
Cambodia1
China1
France1
Greece1
India1
Italy1
Jordan1
Mexico1
Peru1
UK1
USA1
UNESCO_StatusFrequency
Yes12
Tourism_CategoryFrequency
Mass Budget2
Niche Budget4
Niche Premium4
Premium Mass2
Frequency
Row Pct
Col Pct
Table of UNESCO_Status by Tourism_Category
UNESCO_StatusTourism_Category
Mass BudgetNiche BudgetNiche PremiumPremium MassTotal
Yes
2
16.67
100.00
4
33.33
100.00
4
33.33
100.00
2
16.67
100.00
12
 
 
Total
2
4
4
2
12

Step 6: Numeric summary with PROC MEANS 

proc means data=work.monuments_final n mean median min max maxdec=2;

    var Visitors_per_Year Entry_Fee Years_Since_Construction;

run;

OUTPUT:

The MEANS Procedure

VariableNMeanMedianMinimumMaximum
Visitors_per_Year
Entry_Fee
Years_Since_Construction
12
12
5
4225000.00
32.92
53.20
2400000.00
32.50
136.00
1200000.00
20.00
-475.00
10000000.00
50.00
372.00

/* By country */

proc means data=work.monuments_final n mean min max maxdec=2;

    class Country;

    var Visitors_per_Year Entry_Fee;

run;

OUTPUT:

The MEANS Procedure

CountryN ObsVariableNMeanMinimumMaximum
Brazil1
Visitors_per_Year
Entry_Fee
1
1
2000000.00
35.00
2000000.00
35.00
2000000.00
35.00
Cambodia1
Visitors_per_Year
Entry_Fee
1
1
2500000.00
37.00
2500000.00
37.00
2500000.00
37.00
China1
Visitors_per_Year
Entry_Fee
1
1
10000000.00
40.00
10000000.00
40.00
10000000.00
40.00
France1
Visitors_per_Year
Entry_Fee
1
1
7000000.00
30.00
7000000.00
30.00
7000000.00
30.00
Greece1
Visitors_per_Year
Entry_Fee
1
1
2000000.00
20.00
2000000.00
20.00
2000000.00
20.00
India1
Visitors_per_Year
Entry_Fee
1
1
9000000.00
50.00
9000000.00
50.00
9000000.00
50.00
Italy1
Visitors_per_Year
Entry_Fee
1
1
7500000.00
20.00
7500000.00
20.00
7500000.00
20.00
Jordan1
Visitors_per_Year
Entry_Fee
1
1
1200000.00
35.00
1200000.00
35.00
1200000.00
35.00
Mexico1
Visitors_per_Year
Entry_Fee
1
1
2300000.00
30.00
2300000.00
30.00
2300000.00
30.00
Peru1
Visitors_per_Year
Entry_Fee
1
1
1500000.00
45.00
1500000.00
45.00
1500000.00
45.00
UK1
Visitors_per_Year
Entry_Fee
1
1
1400000.00
28.00
1400000.00
28.00
1400000.00
28.00
USA1
Visitors_per_Year
Entry_Fee
1
1
4300000.00
25.00
4300000.00
25.00
4300000.00
25.00

Step 7: Scatter plot of visitors vs. entry fee 

proc sgplot data=work.monuments_final;

    scatter x=Entry_Fee y=Visitors_per_Year / group=UNESCO_Status;

    xaxis label="Entry Fee";

    yaxis label="Visitors per Year";

    title "Visitors vs Entry Fee by UNESCO Status";

run;

OUTPUT:

The SGPlot Procedure

/* Bar chart: total visitors per country */

proc sgplot data=work.monuments_final;

    vbar Country / response=Visitors_per_Year stat=sum;

    yaxis label="Total Visitors per Year";

    title "Total Annual Visitors by Country";

run;

OUTPUT:
The SGPlot Procedure





To Visit My Previous Software Company Analysis Dataset:Click Here
To Visit My Previous Vote Program Dataset:Click Here
To Visit My Previous Audi Cars Performance Analysis Dataset:Click Here
To Visit My Previous Global Clothing Trends Dataset:Click Here  



Follow Us On : 


 


--- FOLLOW OUR BLOG FOR MORE INFORMATION.

--->PLEASE DO COMMENTS AND SHARE OUR BLOG.





No comments:

Post a Comment