




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
2025年統(tǒng)計學(xué)專業(yè)期末考試:統(tǒng)計軟件應(yīng)用與SAS操作試題庫考試時間:______分鐘總分:______分姓名:______一、SAS基礎(chǔ)操作要求:掌握SAS基本數(shù)據(jù)編輯、數(shù)據(jù)轉(zhuǎn)換和基本數(shù)據(jù)分析操作。1.使用SAS創(chuàng)建以下數(shù)據(jù)集:-數(shù)據(jù)集名為“students”,包含以下字段:student_id(學(xué)生ID,字符型),name(姓名,字符型),age(年齡,數(shù)值型),gender(性別,字符型)。-輸入以下數(shù)據(jù):1.student_id:A001,name:張三,age:20,gender:男2.student_id:A002,name:李四,age:21,gender:女3.student_id:A003,name:王五,age:22,gender:男4.student_id:A004,name:趙六,age:23,gender:女5.student_id:A005,name:周七,age:24,gender:男2.將“students”數(shù)據(jù)集中的年齡字段轉(zhuǎn)換為年齡組(20歲以下、20-30歲、30歲以上),并將結(jié)果輸出到新數(shù)據(jù)集“age_group”中。3.在“students”數(shù)據(jù)集中,將性別字段中的“男”和“女”分別替換為“M”和“F”。4.從“students”數(shù)據(jù)集中篩選出年齡在20-30歲之間的學(xué)生,并將結(jié)果輸出到新數(shù)據(jù)集“age_20_30”中。5.統(tǒng)計“students”數(shù)據(jù)集中男性和女性的數(shù)量,并將結(jié)果輸出到新數(shù)據(jù)集“gender_count”中。6.計算學(xué)生平均年齡,并將結(jié)果輸出到新數(shù)據(jù)集“average_age”中。7.將“students”數(shù)據(jù)集中的學(xué)生姓名按照字典序進(jìn)行排序,并將結(jié)果輸出到新數(shù)據(jù)集“sorted_name”中。8.將“students”數(shù)據(jù)集中的學(xué)生ID按照升序進(jìn)行排序,并將結(jié)果輸出到新數(shù)據(jù)集“sorted_id”中。9.從“students”數(shù)據(jù)集中刪除重復(fù)的學(xué)生記錄,并將結(jié)果輸出到新數(shù)據(jù)集“unique_students”中。10.將“students”數(shù)據(jù)集中的學(xué)生姓名和年齡合并為一個字段,并輸出到新數(shù)據(jù)集“name_age”中。二、SAS程序設(shè)計要求:掌握SAS程序設(shè)計的基本語法和流程控制。1.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“sales”的數(shù)據(jù)集,包含以下字段:product_id(產(chǎn)品ID,字符型),quantity(數(shù)量,數(shù)值型),price(價格,數(shù)值型)。-輸入以下數(shù)據(jù):1.product_id:P001,quantity:10,price:1002.product_id:P002,quantity:20,price:2003.product_id:P003,quantity:15,price:1504.product_id:P004,quantity:5,price:505.product_id:P005,quantity:30,price:300-計算每個產(chǎn)品的總銷售額,并將結(jié)果輸出到新數(shù)據(jù)集“total_sales”中。2.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“grades”的數(shù)據(jù)集,包含以下字段:student_id(學(xué)生ID,字符型),subject(科目,字符型),score(分?jǐn)?shù),數(shù)值型)。-輸入以下數(shù)據(jù):1.student_id:A001,subject:數(shù)學(xué),score:902.student_id:A001,subject:英語,score:853.student_id:A002,subject:數(shù)學(xué),score:804.student_id:A002,subject:英語,score:905.student_id:A003,subject:數(shù)學(xué),score:706.student_id:A003,subject:英語,score:75-計算每個學(xué)生的平均成績,并將結(jié)果輸出到新數(shù)據(jù)集“average_grades”中。3.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“weather”的數(shù)據(jù)集,包含以下字段:date(日期,字符型),temperature(溫度,數(shù)值型),humidity(濕度,數(shù)值型)。-輸入以下數(shù)據(jù):1.date:2025-01-01,temperature:5,humidity:702.date:2025-01-02,temperature:6,humidity:653.date:2025-01-03,temperature:7,humidity:604.date:2025-01-04,temperature:8,humidity:555.date:2025-01-05,temperature:9,humidity:50-統(tǒng)計每個日期的平均溫度和濕度,并將結(jié)果輸出到新數(shù)據(jù)集“average_weather”中。4.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“sales”的數(shù)據(jù)集,包含以下字段:product_id(產(chǎn)品ID,字符型),quantity(數(shù)量,數(shù)值型),price(價格,數(shù)值型)。-輸入以下數(shù)據(jù):1.product_id:P001,quantity:10,price:1002.product_id:P002,quantity:20,price:2003.product_id:P003,quantity:15,price:1504.product_id:P004,quantity:5,price:505.product_id:P005,quantity:30,price:300-統(tǒng)計每個產(chǎn)品的銷售數(shù)量,并按照銷售數(shù)量降序排列,將結(jié)果輸出到新數(shù)據(jù)集“sales_rank”中。5.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“grades”的數(shù)據(jù)集,包含以下字段:student_id(學(xué)生ID,字符型),subject(科目,字符型),score(分?jǐn)?shù),數(shù)值型)。-輸入以下數(shù)據(jù):1.student_id:A001,subject:數(shù)學(xué),score:902.student_id:A001,subject:英語,score:853.student_id:A002,subject:數(shù)學(xué),score:804.student_id:A002,subject:英語,score:905.student_id:A003,subject:數(shù)學(xué),score:706.student_id:A003,subject:英語,score:75-統(tǒng)計每個科目的平均成績,并按照平均成績降序排列,將結(jié)果輸出到新數(shù)據(jù)集“subject_grades”中。6.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“weather”的數(shù)據(jù)集,包含以下字段:date(日期,字符型),temperature(溫度,數(shù)值型),humidity(濕度,數(shù)值型)。-輸入以下數(shù)據(jù):1.date:2025-01-01,temperature:5,humidity:702.date:2025-01-02,temperature:6,humidity:653.date:2025-01-03,temperature:7,humidity:604.date:2025-01-04,temperature:8,humidity:555.date:2025-01-05,temperature:9,humidity:50-統(tǒng)計每個溫度區(qū)間的日期數(shù)量,并將結(jié)果輸出到新數(shù)據(jù)集“temperature_interval”中。7.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“sales”的數(shù)據(jù)集,包含以下字段:product_id(產(chǎn)品ID,字符型),quantity(數(shù)量,數(shù)值型),price(價格,數(shù)值型)。-輸入以下數(shù)據(jù):1.product_id:P001,quantity:10,price:1002.product_id:P002,quantity:20,price:2003.product_id:P003,quantity:15,price:1504.product_id:P004,quantity:5,price:505.product_id:P005,quantity:30,price:300-統(tǒng)計每個價格區(qū)間的銷售數(shù)量,并將結(jié)果輸出到新數(shù)據(jù)集“price_interval”中。8.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“grades”的數(shù)據(jù)集,包含以下字段:student_id(學(xué)生ID,字符型),subject(科目,字符型),score(分?jǐn)?shù),數(shù)值型)。-輸入以下數(shù)據(jù):1.student_id:A001,subject:數(shù)學(xué),score:902.student_id:A001,subject:英語,score:853.student_id:A002,subject:數(shù)學(xué),score:804.student_id:A002,subject:英語,score:905.student_id:A003,subject:數(shù)學(xué),score:706.student_id:A003,subject:英語,score:75-統(tǒng)計每個分?jǐn)?shù)區(qū)間的學(xué)生數(shù)量,并將結(jié)果輸出到新數(shù)據(jù)集“score_interval”中。9.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“weather”的數(shù)據(jù)集,包含以下字段:date(日期,字符型),temperature(溫度,數(shù)值型),humidity(濕度,數(shù)值型)。-輸入以下數(shù)據(jù):1.date:2025-01-01,temperature:5,humidity:702.date:2025-01-02,temperature:6,humidity:653.date:2025-01-03,temperature:7,humidity:604.date:2025-01-04,temperature:8,humidity:555.date:2025-01-05,temperature:9,humidity:50-統(tǒng)計每個濕度區(qū)間的日期數(shù)量,并將結(jié)果輸出到新數(shù)據(jù)集“humidity_interval”中。10.編寫一個SAS程序,實現(xiàn)以下功能:-定義一個名為“sales”的數(shù)據(jù)集,包含以下字段:product_id(產(chǎn)品ID,字符型),quantity(數(shù)量,數(shù)值型),price(價格,數(shù)值型)。-輸入以下數(shù)據(jù):1.product_id:P001,quantity:10,price:1002.product_id:P002,quantity:20,price:2003.product_id:P003,quantity:15,price:1504.product_id:P004,quantity:5,price:505.product_id:P005,quantity:30,price:300-統(tǒng)計每個產(chǎn)品的銷售數(shù)量和價格,并將結(jié)果輸出到新數(shù)據(jù)集“sales_price”中。四、SAS宏變量和循環(huán)要求:掌握SAS宏變量的定義、賦值和使用,以及循環(huán)語句的基本語法和應(yīng)用。1.定義一個宏變量名為“max_value”,并將其賦值為100。2.使用宏變量在SAS代碼中輸出“max_value”的值。3.編寫一個宏程序,該程序接受一個參數(shù),并輸出該參數(shù)值的平方。4.使用宏程序計算并輸出以下數(shù)值的平方:10,20,30,40,50。5.編寫一個循環(huán),從1迭代到10,并在每次迭代中輸出迭代變量的值。6.使用循環(huán)將以下字符數(shù)組中的每個字符輸出到不同的行:-字符數(shù)組:'abcdefghijklmnopqrstuvwxyz'7.編寫一個宏變量循環(huán),從1迭代到5,并在每次迭代中輸出當(dāng)前迭代的宏變量值。8.使用宏變量和循環(huán),創(chuàng)建一個名為“numbers”的數(shù)據(jù)集,包含字段“number”,其中包含從1到10的數(shù)字。9.使用宏變量和循環(huán),將“numbers”數(shù)據(jù)集中的“number”字段乘以2,并將結(jié)果輸出到新數(shù)據(jù)集“doubled_numbers”中。10.使用宏變量和循環(huán),創(chuàng)建一個名為“strings”的數(shù)據(jù)集,包含字段“string”,其中包含從'a'到'j'的字母。五、SAS數(shù)據(jù)處理要求:掌握SAS數(shù)據(jù)集的合并、連接和子集操作。1.定義兩個數(shù)據(jù)集“data1”和“data2”,其中“data1”包含字段“id”和“value”,而“data2”包含字段“id”和“description”。2.使用SAS代碼合并“data1”和“data2”數(shù)據(jù)集,并創(chuàng)建一個新數(shù)據(jù)集“merged_data”,其中包含所有字段。3.使用SAS代碼連接“data1”和“data2”數(shù)據(jù)集,基于字段“id”,并創(chuàng)建一個新數(shù)據(jù)集“connected_data”。4.從“merged_data”數(shù)據(jù)集中刪除所有“value”字段值為空的數(shù)據(jù)行。5.從“connected_data”數(shù)據(jù)集中選擇所有“description”字段包含“text”的數(shù)據(jù)行。6.使用SAS代碼創(chuàng)建“data1”數(shù)據(jù)集的子集,僅包含“id”字段值為偶數(shù)的記錄。7.使用SAS代碼將“data1”數(shù)據(jù)集中的“id”字段值添加到“data2”數(shù)據(jù)集中的末尾,并創(chuàng)建一個新數(shù)據(jù)集“extended_data”。8.使用SAS代碼對“merged_data”數(shù)據(jù)集中的“value”字段進(jìn)行排序,并創(chuàng)建一個新數(shù)據(jù)集“sorted_data”。9.使用SAS代碼計算“connected_data”數(shù)據(jù)集中每個唯一“id”的總和,并創(chuàng)建一個新數(shù)據(jù)集“sums_by_id”。10.使用SAS代碼對“extended_data”數(shù)據(jù)集中的“id”字段進(jìn)行去重,并創(chuàng)建一個新數(shù)據(jù)集“unique_extended_data”。六、SAS數(shù)據(jù)可視化要求:掌握SAS圖形和數(shù)據(jù)可視化的基本操作。1.使用SAS代碼創(chuàng)建一個簡單的條形圖,展示“data1”數(shù)據(jù)集中的“value”字段值。2.使用SAS代碼創(chuàng)建一個折線圖,展示“data2”數(shù)據(jù)集中的“value”字段隨時間的變化。3.使用SAS代碼創(chuàng)建一個散點圖,展示“data1”和“data2”數(shù)據(jù)集的“value”字段之間的關(guān)系。4.使用SAS代碼創(chuàng)建一個餅圖,展示“data1”數(shù)據(jù)集中“id”字段的分布。5.使用SAS代碼將上述創(chuàng)建的圖形保存為PNG文件。6.使用SAS代碼創(chuàng)建一個復(fù)式條形圖,展示“data1”數(shù)據(jù)集中的“value”字段按“id”字段的分組。7.使用SAS代碼創(chuàng)建一個堆積柱狀圖,展示“data2”數(shù)據(jù)集中的“value”字段隨時間的變化。8.使用SAS代碼創(chuàng)建一個三維散點圖,展示“data1”和“data2”數(shù)據(jù)集的三個數(shù)值字段之間的關(guān)系。9.使用SAS代碼將上述創(chuàng)建的圖形添加到同一個圖形窗口中。10.使用SAS代碼將上述創(chuàng)建的圖形保存為PDF文件。本次試卷答案如下:一、SAS基礎(chǔ)操作1.創(chuàng)建數(shù)據(jù)集“students”:```sasdatastudents;inputstudent_id$name$agegender$;datalines;A001張三20男A002李四21女A003王五22男A004趙六23女A005周七24男;run;```2.轉(zhuǎn)換年齡字段到年齡組:```sasdataage_group;setstudents;ifage<20thenage_group='20歲以下';elseifage>=20andage<30thenage_group='20-30歲';elseage_group='30歲以上';run;```3.替換性別字段:```sasdatastudents;setstudents;ifgender='男'thengender='M';elseifgender='女'thengender='F';run;```4.篩選20-30歲學(xué)生:```sasdataage_20_30;setstudents;ifage>=20andage<30;run;```5.統(tǒng)計男性和女性數(shù)量:```sasdatagender_count;setstudents;ifgender='M'thenmale_count=male_count+1;elseifgender='F'thenfemale_count=female_count+1;run;```6.計算平均年齡:```sasdataaverage_age;setstudents;average_age=mean(age);run;```7.按姓名排序:```sasdatasorted_name;setstudents;byname;run;```8.按學(xué)生ID排序:```sasdatasorted_id;setstudents;bystudent_id;run;```9.刪除重復(fù)記錄:```sasdataunique_students;setstudents;bystudent_id;drop_all_;if_n_>1thendelete;run;```10.合并姓名和年齡:```sasdataname_age;setstudents;name_age=catx('',name,age);run;```二、SAS程序設(shè)計1.計算每個產(chǎn)品的總銷售額:```sasdatatotal_sales;setsales;total_sales=quantity*price;run;```2.計算每個學(xué)生的平均成績:```sasdataaverage_grades;setgrades;average_grade=mean(score);run;```3.統(tǒng)計每個日期的平均溫度和濕度:```sasdataaverage_weather;setweather;bydate;average_temp=mean(temperature);average_humidity=mean(humidity);run;```4.統(tǒng)計每個產(chǎn)品的銷售數(shù)量,按數(shù)量降序排列:```sasprocsortdata=salesout=sales_rank;byquantitydescending;run;```5.統(tǒng)計每個科目的平均成績,按平均成績降序排列:```sasprocsortdata=gradesout=subject_grades;bysubjectdescending;run;```6.統(tǒng)計每個溫度區(qū)間的日期數(shù)量:```sasdatatemperature_interval;setweather;iftemperature<6thentemp_interval='低溫';elseiftemperature>=6andtemperature<8thentemp_interval='中溫';elsetemp_interval='高溫';bytemp_interval;count=count+1;run;```7.統(tǒng)計每個價格區(qū)間的銷售數(shù)量:```sasdataprice_interval;setsales;ifprice<100thenprice_interval='低價';elseifprice>=100andprice<200thenprice_interval='中價';elseprice_interval='高價';byprice_interval;count=count+1;run;```8.統(tǒng)計每個分?jǐn)?shù)區(qū)間的學(xué)生數(shù)量:```sasdatascore_interval;setgrades;ifscore<70thenscore_interval='不及格';elseifscore>=70andscore<80thenscore_interval='中等';elseifscore>=80andscore<90thenscore_interval='良好';elsescore_interval='優(yōu)秀';byscore_interval;count=count+1;run;```9.統(tǒng)計每個濕度區(qū)間的日期數(shù)量:```sasdatahumidity_interval;setweather;ifhumidity<60thenhum_interval='低濕';elseifhumidity>=60andhumidity<70thenhum_interval='中濕';elsehum_interval='高濕';byhum_interval;count=count+1;run;```10.統(tǒng)計每個產(chǎn)品的銷售數(shù)量和價格:```sasdatasales_price;setsales;output;setsales;output;run;```四、SAS宏變量和循環(huán)1.定義宏變量并輸出值:```sas%letmax_value=100;put&max_value;```2.使用宏變量輸出平方值:```sas%macrosquare(value);%letsquare_value=&value**2;put&square_value;%mend;%square(10);%square(20);%square(30);%square(40);%square(50);```3.宏程序計算平方:```sas%macrosquare(value);%letsquare_value=&value**2;%put&square_value;%mend;%square(10);%square(20);%square(30);%square(40);%square(50);```4.循環(huán)輸出10到50的平方:```sas%leti=10;%do%while(&i<=50);%letsquare_value=&i**2;put&square_value;%leti=&i+1;%end;```5.循環(huán)輸出字符數(shù)組中的每個字符:```sas%leti=1;%letstring='abcdefghijklmnopqrstuvwxyz';%do%while(&i<=length(&string));putsubstr(&string,&i,1);%leti=&i+1;%end;```6.宏變量循環(huán)輸出1到5的值:```sas%leti=1;%do%while(&i<=5);%letvalue=&i;put&value;%leti=&i+1;%end;```7.創(chuàng)建“numbers”數(shù)據(jù)集:```sasdatanumbers;donumber=1to10;output;end;run;```8.將“numbers”數(shù)據(jù)集中的“number”字段乘以2:```sasdatadoubled_numbers;setnumbers;doubled_number=number*2;run;```9.創(chuàng)建“strings”數(shù)據(jù)集:```sasdatastrings;doi=97to106;output;end;run;```五、SAS數(shù)據(jù)處理1.合并“data1”和“data2”數(shù)據(jù)集:```sasdatamerged_data;mergedata1data2;byid;run;```2.連接“data1”和“data2”數(shù)據(jù)集:```sasprocsortdata=data1out=data1_sorted;byid;procsortdata=data2out=data2_sorted;byid;dataconnected_data;mergedata1_sorteddata2_sorted;byid;run;```3.刪除“merged_data”數(shù)據(jù)集中的空值:```sasdatamerged_data_clean;setmerged_data;ifvaluene.;run;```4.選擇“connected_data”數(shù)據(jù)集中的特定描述:```sasdataselected_data;setconnected_data;ifdescriptioncontains'text';run;```5.創(chuàng)建“data1”數(shù)據(jù)集的子集:```sasdatasubset_data1;setdata1;ifmod(id,2)=0;run;```6.將“data1”數(shù)據(jù)集中的“id”字段添加到“data2”數(shù)據(jù)集末尾:```sasdataextended_data;setdata2;datatemp;setdata1;run;mergeextended_datatemp;byid;drop_all_;run;```7.對“merged_data”數(shù)據(jù)集中的“value”字段排序:```sasprocsortdata=merged_dataout=sorted_data;byvalue;run;```8.計算“connected_data”數(shù)據(jù)集中每個唯一“id”的總和:```sasprocsortdata=connected_dataout=connected_data_sorted;byid;datasums_by_id
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 有趣早教科學(xué)課件
- 存貨管理策略與實踐
- 血液透析患者血鉀管理
- 安裝紗窗合同協(xié)議書
- 船舶項目合同協(xié)議書
- 茶葉定購合同協(xié)議書
- 合同變更稅率協(xié)議書
- 拆遷合同轉(zhuǎn)讓協(xié)議書
- 雙方交易合同協(xié)議書
- 口腔科前臺管理優(yōu)化方案
- 《危險化學(xué)品企業(yè)安全生產(chǎn)標(biāo)準(zhǔn)化規(guī)范》專業(yè)深度解讀與應(yīng)用培訓(xùn)指導(dǎo)材料之6:5管理要求-5.6 設(shè)備完整性(雷澤佳編制-2025A0)
- 市場調(diào)查與分析(完全)
- 臨床專業(yè)考試試題及答案
- 2024年黑龍江帕弗爾能源產(chǎn)業(yè)管理有限公司高校畢業(yè)生招聘筆試真題
- 初中家長學(xué)校父母課堂課件與教案
- 2025年軟件設(shè)計師模擬試卷:操作系統(tǒng)與計算機(jī)網(wǎng)絡(luò)核心知識點精講
- 裸眼3D研究報告裸眼3D項目商業(yè)計劃書(2025年)
- 芯片知識課件下載
- 計算機(jī)組成原理練習(xí)題(含參考答案)
- 部編版六年級下冊《道德與法治》知識點匯編
- (四調(diào))武漢市2025屆高中畢業(yè)生四月調(diào)研考試 生物試卷(含答案)
評論
0/150
提交評論