1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 2 TITLE; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 3 FOOTNOTE; 4 OPTIONS LOCALE=en_US DFLANG=LOCALE; 5 DATA _NULL_; 6 RUN; 7 OPTIONS VALIDVARNAME=ANY; 8 OPTIONS VALIDMEMNAME=EXTEND; 9 FILENAME _HTMLOUT TEMP; 10 FILENAME _GSFNAME TEMP; 11 FILENAME _DATAOUT TEMP; 12 %LET SYSCC=0; 13 %LET _CLIENTAPP='SAS Studio'; 14 %LET _CLIENTAPPABREV=Studio; 15 %LET _CLIENTAPPVERSION=3.8; 16 %LET _CLIENTVERSION=3.8; 17 %LET _CLIENTMODE=wip; 18 %LET _SASSERVERNAME=%BQUOTE(SASApp); 19 %LET _SASHOSTNAME=%BQUOTE(odaws01-usw2-2); 20 %LET _SASPROGRAMFILEHOST=%BQUOTE(odaws01-usw2-2); 21 %LET _CLIENTUSERID=%BQUOTE(u62193446); 22 %LET _CLIENTUSERNAME=%BQUOTE(u62193446); 23 %LET CLIENTMACHINE=%BQUOTE(096-035-054-050.RES.SPECTRUM.COM); 24 %LET _CLIENTMACHINE=%BQUOTE(096-035-054-050.RES.SPECTRUM.COM); 25 %let SASWORKLOCATION="%sysfunc(getoption(work))/"; 26 FILENAME _CWD '.'; 27 DATA _NULL_; 28 CALL SYMPUT('_SASWORKINGDIR',PATHNAME('_CWD')); 29 RUN; 30 FILENAME _CWD; 31 32 %LET _SASPROGRAMFILE = %NRQUOTE(%NRSTR(/home/u62193446/Week6/Project6.sas)); NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. ________________________________________________________________________________________________________________________ 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 33 %LET _BASEURL = %BQUOTE(https://odamid-usw2-2.oda.sas.com/SASStudio/); 34 %LET _EXECENV=SASStudio; 35 DATA _NULL_; 36 CALL 36 ! SYMPUT("GRAPHINIT" _ 49 36 ! ,""); 37 CALL 37 ! SYMPUT("GRAPHTERM" _ 49 37 ! ,""); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 38 RC=TSLVL('SASXGOPT','N'); 39 _ERROR_=0; 40 IF (RC^=' ') THEN DO; 41 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;"); ___ ________________ 49 49 42 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;"); ___ ___________________________________ 49 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 43 END; 44 RUN; 45 DATA _NULL_; 46 RC=SYSPROD("PRODNUM002" _ 49 46 ! ); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 47 IF (RC^=1) THEN DO; 48 CALL 48 ! SYMPUT("GRAPHINIT" _ 49 48 ! ,""); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 49 CALL SYMPUT("GRAPHTERM",""); 50 END; 51 RUN; 52 %LET _DATAOUT_MIME_TYPE=; 53 %LET _DATAOUT_NAME=; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 54 %LET _DATAOUT_TABLE=; 55 %LET _DATAOUT_URL=; 56 %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE; 57 %LET _SASWS_ = %BQUOTE(/home/u62193446); 58 %LET _SASWSTEMP_=%BQUOTE(/home/u62193446/.sasstudio/.images/de4be329-08f3-43d7-9756-cdf75a8e35b3); 59 ODS LISTING CLOSE; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 60 ODS AUTONAVIGATE OFF; 61 ODS GRAPHICS ON; 62 ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8 FILE=_HTMLOUT (TITLE='Results: Project6.sas') 62 ! STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE' 62 ! CSS_PREFIX='.ods_de4be329-08f3-43d7-9756-cdf75a8e35b3' BODY_ID='div_de4be329-08f3-43d7-9756-cdf75a8e35b3' ); 63 &GRAPHINIT; 64 OPTIONS FIRSTOBS=1; 65 OPTIONS OBS=MAX; 66 OPTIONS DTRESET DATE NUMBER NOTES; 67 %put %bquote(NOTE: ODS statements in the SAS Studio environment may disable some output features.); 68 OPTIONS NOTES STIMER SOURCE NOSYNTAXCHECK; 69 70 71 * Problem - MACROS; 72 *1.1 Use %LET to create a macro variable named ClassAge, assigning to it a value of Pre-K 4; 73 74 %LET ClassAge = Pre-K 4; 75 76 *------------------------------------------------------------------------------------------------------------------------ 76 ! ---------------------------------; 77 78 *1.2 Read the data set from the file '/folders/myfolders/Week6/School 1 final.csv' and name it final.; 79 * Then use IF to subset with the macro variable &ClassAge. Name the subset as ClassAge_final. Print it; 80 * using the macro variable in TITLE. ; 81 LIBNAME Week6 '/home/u62193446/Week6'; 82 DATA final; 83 INFILE '/home/u62193446/Week6/school 1 finale.csv' DSD FIRSTOBS = 2; 84 INPUT ClassIDChildIDGender$ClassAge$Language$f1f2f3f4; 85 IF ClassAge = "&ClassAge"; 86 RUN; 87 88 PROC PRINT DATA = final; 89 TITLE "&ClassAge_final"; 90 RUN; 91 NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 92 93 94 *------------------------------------------------------------------------------------------------------------------------ 94 ! ----------------------------------; 95 96 *1.3 Create a macro named average with two parameters category and question. In the macro, firstly; 97 *apply PROC MEANS for the data set final to calculate the mean of &question by &category. In the PROC MEANS,; 98 *use option NOPRINT, and let OUT=averagescore. Then apply PROC PRINT to print the data averagescore using; 99 *the macro variables in the TITLE.; 100 101 %MACRO average(category=, question=); 102 103 104 PROC MEANS DATA = final MEAN NOPRINT; 105 CLASS &category; 106 VAR &question; 107 OUTPUT OUT = averagescore; 108 RUN; 109 110 111 PROC PRINT DATA = averagescore; 112 TITLE "&category &questions"; 113 RUN; 114 %MEND average; 115 NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 116 *------------------------------------------------------------------------------------------------------------------------ 116 ! ------------------------------; 117 118 * 1.4 Invoke the macro %average(category=Gender, question=f1).; 119 120 %MACRO average(category=Gender, question=f1); 121 122 123 *------------------------------------------------------------------------------------------------------------------------ 123 ! -------------------------------; 124 125 126 *1.5Invoke the macro %average(category= ClassAge, question=f3); 127 %MACRO average(category= ClassAge, question=f3); 128 129 *------------------------------------------------------------------------------------------------------------------------ 129 ! --------------------------------; 130 131 *1.6 Create a macro named class with one parameter category. In the macro, use %IF &category =Gender; 132 *%THEN %DO; PROC MEANS for the data final to calculate the mean of the variable f1 by &category.; 133 *%ELSE %IF &category =ClassAge %THEN %DO; PROC MEANS for the data final to calculate the mean of the; 134 * variable f2 by &category.; 135 136 %MACRO class(category=); 137 %IF &category =Gender*%THEN %DO; 138 PROC MEANS DATA = final MEAN MAXDEC=0 ; 139 VAR f1; 140 BY &category; 141 RUN; 142 %END; 143 144 %ELSE %IF &category = ClassAge %THEN %DO; 145 PROC MEANS DATA = final MEAN MAXDEC=0; 146 VAR f2; 147 BY &category; 148 TITLE "&category for f1 and f2"; 149 RUN; 150 151 %END; 152 %MEND category; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 153 154 *------------------------------------------------------------------------------------------------------------------------ 154 ! ----------------------------------; 155 156 *1.7Call the macro %class(category=Gender); 157 %MACRO class(category=Gender); 158 159 *------------------------------------------------------------------------------------------------------------------------ 159 ! ----------------------------------; 160 161 *1.8Call the macro %class(category=ClassAge); 162 %MACRO class(category=ClassAge); 163 164 165 ************************************************************************************************************************* 165 ! *********************************; 166 * Problem - 2 Visualisation; 167 ************************************************************************************************************************* 167 ! *********************************; 168 *2.1Read the data from the file: '/folders/myfolders/Week6/2010-2015-Age65above Final Death Count.csv'; 169 *with INPUT year month gender $ age ICD10 $ death; Name the data as death_count.; 170 171 LIBNAME Week6 '/home/u62193446/Week6'; 172 DATA death_count; 173 INFILE '/home/u62193446/Week6/2010-2015-Age65above Final Death Counts.csv' DSD FIRSTOBS = 2; 174 INPUT year month gender $ age ICD10 $ death; 175 RUN; 176 177 *------------------------------------------------------------------------------------------------------------------------ 177 ! -----------------------------------; 178 *2.2Use PROC MEANS to get the total death of each year.; 179 *Create a horizontal Bar Chart for the total death of each year.; 180 181 182 proc means data = death_count noprint; 183 var death; 184 class year; 185 output OUT = death_by_year 186 SUM(death) = total_death; 187 TITLE 'Total Death by Year'; 188 RUN; 189 190 191 * Bar chart for total death for each year; 192 PROC SGPLOT DATA = death_count; 193 HBAR year / STAT=SUM RESPONSE =death; 194 TITLE1 'Total Death By Year'; 195 196 RUN; 197 *------------------------------------------------------------------------------------------------------------------------ 197 ! -----------------------------------; 198 199 *2.3 Use PROC MEANS to get total death by ICD10. Create a scatter plot for the total death by ICD 10.; 200 *Label the x-axis as ‘Death Code’, y-axis as ‘Total Death’, and save the graph as; 201 * ‘Scatter plot total death by Death Code.png’; 202 203 proc means data = death_count noprint; 204 var death; 205 class ICD10; 206 output OUT = death_by_ICD 207 SUM(death) = total_death; 208 TITLE 'Total Death by ICD'; 209 RUN; 210 211 212 *Creating Scatter plot; 213 214 ODS LISTING GPATH ='/home/u62193446/Week6'; 215 ODS GRAPHICS / RESET 216 IMAGENAME = 'Scatterplot totaldeath by Deathcode' 217 OUTPUTFMT = PNG 218 HEIGHT = 3IN WIDTH = 6IN; 219 220 proc sgplot data=death_count; 221 scatter x=ICD10 y=death /; 222 xaxis grid; 223 yaxis grid; 224 run; 225 *------------------------------------------------------------------------------------------------------------------------ 225 ! -----------------------------------; 226 227 *2.4Create a histogram for the death where the ICD=52.; 228 229 *read select and save icd10 data rows; 230 LIBNAME Week6 '/home/u62193446/Week6'; 231 DATA death_count; 232 INFILE '/home/u62193446/Week6/2010-2015-Age65above Final Death Counts.csv' DSD FIRSTOBS = 2; 233 INPUT year month gender $ age ICD10 $ death; 234 RUN; 235 236 * subquery; 237 proc sql; 238 title 'icd10'; 148 TITLE "&category for f1 and f2"; __ 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 239 select ICD10 , death 240 from Work.death_count; 241 where ICD10 = 242 (select ICD10 from Work.death_count 243 where ICD10 = "52"); 244 quit; 245 246 247 248 proc sgplot data=WORK.DEATH_COUNT; 249 histogram death /; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 250 yaxis grid; 251 run; 252 *------------------------------------------------------------------------------------------------------------------------ 252 ! ----------------------------------; 253 254 *2.5Create a vertical box plot for the death with category =gender.; 255 PROC SGPLOT DATA = death_count; 256 VBOX death/ CATEGORY = gender; 257 TITLE 'Vertical Boxplot Death by Gender'; 258 RUN; 259 *------------------------------------------------------------------------------------------------------------------------ 259 ! ----------------------------------; 260 261 *2.6Create a horizontal box plot for the death with category =month. Save the graph as; 262 *‘Boxplot death by month.png’.; 263 264 265 * Create box plot; 266 ODS LISTING GPATH ='/home/u62193446/Week6'; 267 ODS GRAPHICS / RESET 268 IMAGENAME = 'Boxplot death by Month' 269 OUTPUTFMT = PNG 270 HEIGHT = 3IN WIDTH = 6IN; 271 272 PROC SGPLOT DATA = death_count; 273 HBOX death/ CATEGORY = month; 274 TITLE 'Horizontal Boxplot Death by Month'; 275 RUN; 276 277 278 *######################################################################################################################## 278 ! ##################################; 279 280 281 282 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 283 ODS HTML CLOSE; 284 &GRAPHTERM; ;*';*";*/;RUN;QUIT; 285 QUIT;RUN; 286 ODS HTML5 (ID=WEB) CLOSE; 287 288 FILENAME _GSFNAME; 289 DATA _NULL_; 290 RUN; 291 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK; 292 User: u62193446 Messages: 3 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 2 TITLE; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 3 FOOTNOTE; 4 OPTIONS LOCALE=en_US DFLANG=LOCALE; 5 DATA _NULL_; 6 RUN; 7 OPTIONS VALIDVARNAME=ANY; 8 OPTIONS VALIDMEMNAME=EXTEND; 9 FILENAME _HTMLOUT TEMP; 10 FILENAME _GSFNAME TEMP; 11 FILENAME _DATAOUT TEMP; 12 %LET SYSCC=0; 13 %LET _CLIENTAPP='SAS Studio'; 14 %LET _CLIENTAPPABREV=Studio; 15 %LET _CLIENTAPPVERSION=3.8; 16 %LET _CLIENTVERSION=3.8; 17 %LET _CLIENTMODE=wip; 18 %LET _SASSERVERNAME=%BQUOTE(SASApp); 19 %LET _SASHOSTNAME=%BQUOTE(odaws01-usw2-2); 20 %LET _SASPROGRAMFILEHOST=%BQUOTE(odaws01-usw2-2); 21 %LET _CLIENTUSERID=%BQUOTE(u62193446); 22 %LET _CLIENTUSERNAME=%BQUOTE(u62193446); 23 %LET CLIENTMACHINE=%BQUOTE(096-035-054-050.RES.SPECTRUM.COM); 24 %LET _CLIENTMACHINE=%BQUOTE(096-035-054-050.RES.SPECTRUM.COM); 25 %let SASWORKLOCATION="%sysfunc(getoption(work))/"; 26 FILENAME _CWD '.'; 27 DATA _NULL_; 28 CALL SYMPUT('_SASWORKINGDIR',PATHNAME('_CWD')); 29 RUN; 30 FILENAME _CWD; 31 32 %LET _SASPROGRAMFILE = %NRQUOTE(%NRSTR(/home/u62193446/Week6/Project6.sas)); NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. ________________________________________________________________________________________________________________________ 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 33 %LET _BASEURL = %BQUOTE(https://odamid-usw2-2.oda.sas.com/SASStudio/); 34 %LET _EXECENV=SASStudio; 35 DATA _NULL_; 36 CALL 36 ! SYMPUT("GRAPHINIT" _ 49 36 ! ,""); 37 CALL 37 ! SYMPUT("GRAPHTERM" _ 49 37 ! ,""); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 38 RC=TSLVL('SASXGOPT','N'); 39 _ERROR_=0; 40 IF (RC^=' ') THEN DO; 41 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;"); ___ ________________ 49 49 42 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;"); ___ ___________________________________ 49 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 43 END; 44 RUN; 45 DATA _NULL_; 46 RC=SYSPROD("PRODNUM002" _ 49 46 ! ); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 47 IF (RC^=1) THEN DO; 48 CALL 48 ! SYMPUT("GRAPHINIT" _ 49 48 ! ,""); NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 49 CALL SYMPUT("GRAPHTERM",""); 50 END; 51 RUN; 52 %LET _DATAOUT_MIME_TYPE=; 53 %LET _DATAOUT_NAME=; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 54 %LET _DATAOUT_TABLE=; 55 %LET _DATAOUT_URL=; 56 %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE; 57 %LET _SASWS_ = %BQUOTE(/home/u62193446); 58 %LET _SASWSTEMP_=%BQUOTE(/home/u62193446/.sasstudio/.images/de4be329-08f3-43d7-9756-cdf75a8e35b3); 59 ODS LISTING CLOSE; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 60 ODS AUTONAVIGATE OFF; 61 ODS GRAPHICS ON; 62 ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8 FILE=_HTMLOUT (TITLE='Results: Project6.sas') 62 ! STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE' 62 ! CSS_PREFIX='.ods_de4be329-08f3-43d7-9756-cdf75a8e35b3' BODY_ID='div_de4be329-08f3-43d7-9756-cdf75a8e35b3' ); 63 &GRAPHINIT; 64 OPTIONS FIRSTOBS=1; 65 OPTIONS OBS=MAX; 66 OPTIONS DTRESET DATE NUMBER NOTES; 67 %put %bquote(NOTE: ODS statements in the SAS Studio environment may disable some output features.); 68 OPTIONS NOTES STIMER SOURCE NOSYNTAXCHECK; 69 70 71 * Problem - MACROS; 72 *1.1 Use %LET to create a macro variable named ClassAge, assigning to it a value of Pre-K 4; 73 74 %LET ClassAge = Pre-K 4; 75 76 *------------------------------------------------------------------------------------------------------------------------ 76 ! ---------------------------------; 77 78 *1.2 Read the data set from the file '/folders/myfolders/Week6/School 1 final.csv' and name it final.; 79 * Then use IF to subset with the macro variable &ClassAge. Name the subset as ClassAge_final. Print it; 80 * using the macro variable in TITLE. ; 81 LIBNAME Week6 '/home/u62193446/Week6'; 82 DATA final; 83 INFILE '/home/u62193446/Week6/school 1 finale.csv' DSD FIRSTOBS = 2; 84 INPUT ClassIDChildIDGender$ClassAge$Language$f1f2f3f4; 85 IF ClassAge = "&ClassAge"; 86 RUN; 87 88 PROC PRINT DATA = final; 89 TITLE "&ClassAge_final"; 90 RUN; 91 NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 92 93 94 *------------------------------------------------------------------------------------------------------------------------ 94 ! ----------------------------------; 95 96 *1.3 Create a macro named average with two parameters category and question. In the macro, firstly; 97 *apply PROC MEANS for the data set final to calculate the mean of &question by &category. In the PROC MEANS,; 98 *use option NOPRINT, and let OUT=averagescore. Then apply PROC PRINT to print the data averagescore using; 99 *the macro variables in the TITLE.; 100 101 %MACRO average(category=, question=); 102 103 104 PROC MEANS DATA = final MEAN NOPRINT; 105 CLASS &category; 106 VAR &question; 107 OUTPUT OUT = averagescore; 108 RUN; 109 110 111 PROC PRINT DATA = averagescore; 112 TITLE "&category &questions"; 113 RUN; 114 %MEND average; 115 NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 116 *------------------------------------------------------------------------------------------------------------------------ 116 ! ------------------------------; 117 118 * 1.4 Invoke the macro %average(category=Gender, question=f1).; 119 120 %MACRO average(category=Gender, question=f1); 121 122 123 *------------------------------------------------------------------------------------------------------------------------ 123 ! -------------------------------; 124 125 126 *1.5Invoke the macro %average(category= ClassAge, question=f3); 127 %MACRO average(category= ClassAge, question=f3); 128 129 *------------------------------------------------------------------------------------------------------------------------ 129 ! --------------------------------; 130 131 *1.6 Create a macro named class with one parameter category. In the macro, use %IF &category =Gender; 132 *%THEN %DO; PROC MEANS for the data final to calculate the mean of the variable f1 by &category.; 133 *%ELSE %IF &category =ClassAge %THEN %DO; PROC MEANS for the data final to calculate the mean of the; 134 * variable f2 by &category.; 135 136 %MACRO class(category=); 137 %IF &category =Gender*%THEN %DO; 138 PROC MEANS DATA = final MEAN MAXDEC=0 ; 139 VAR f1; 140 BY &category; 141 RUN; 142 %END; 143 144 %ELSE %IF &category = ClassAge %THEN %DO; 145 PROC MEANS DATA = final MEAN MAXDEC=0; 146 VAR f2; 147 BY &category; 148 TITLE "&category for f1 and f2"; 149 RUN; 150 151 %END; 152 %MEND category; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 153 154 *------------------------------------------------------------------------------------------------------------------------ 154 ! ----------------------------------; 155 156 *1.7Call the macro %class(category=Gender); 157 %MACRO class(category=Gender); 158 159 *------------------------------------------------------------------------------------------------------------------------ 159 ! ----------------------------------; 160 161 *1.8Call the macro %class(category=ClassAge); 162 %MACRO class(category=ClassAge); 163 164 165 ************************************************************************************************************************* 165 ! *********************************; 166 * Problem - 2 Visualisation; 167 ************************************************************************************************************************* 167 ! *********************************; 168 *2.1Read the data from the file: '/folders/myfolders/Week6/2010-2015-Age65above Final Death Count.csv'; 169 *with INPUT year month gender $ age ICD10 $ death; Name the data as death_count.; 170 171 LIBNAME Week6 '/home/u62193446/Week6'; 172 DATA death_count; 173 INFILE '/home/u62193446/Week6/2010-2015-Age65above Final Death Counts.csv' DSD FIRSTOBS = 2; 174 INPUT year month gender $ age ICD10 $ death; 175 RUN; 176 177 *------------------------------------------------------------------------------------------------------------------------ 177 ! -----------------------------------; 178 *2.2Use PROC MEANS to get the total death of each year.; 179 *Create a horizontal Bar Chart for the total death of each year.; 180 181 182 proc means data = death_count noprint; 183 var death; 184 class year; 185 output OUT = death_by_year 186 SUM(death) = total_death; 187 TITLE 'Total Death by Year'; 188 RUN; 189 190 191 * Bar chart for total death for each year; 192 PROC SGPLOT DATA = death_count; 193 HBAR year / STAT=SUM RESPONSE =death; 194 TITLE1 'Total Death By Year'; 195 196 RUN; 197 *------------------------------------------------------------------------------------------------------------------------ 197 ! -----------------------------------; 198 199 *2.3 Use PROC MEANS to get total death by ICD10. Create a scatter plot for the total death by ICD 10.; 200 *Label the x-axis as ‘Death Code’, y-axis as ‘Total Death’, and save the graph as; 201 * ‘Scatter plot total death by Death Code.png’; 202 203 proc means data = death_count noprint; 204 var death; 205 class ICD10; 206 output OUT = death_by_ICD 207 SUM(death) = total_death; 208 TITLE 'Total Death by ICD'; 209 RUN; 210 211 212 *Creating Scatter plot; 213 214 ODS LISTING GPATH ='/home/u62193446/Week6'; 215 ODS GRAPHICS / RESET 216 IMAGENAME = 'Scatterplot totaldeath by Deathcode' 217 OUTPUTFMT = PNG 218 HEIGHT = 3IN WIDTH = 6IN; 219 220 proc sgplot data=death_count; 221 scatter x=ICD10 y=death /; 222 xaxis grid; 223 yaxis grid; 224 run; 225 *------------------------------------------------------------------------------------------------------------------------ 225 ! -----------------------------------; 226 227 *2.4Create a histogram for the death where the ICD=52.; 228 229 *read select and save icd10 data rows; 230 LIBNAME Week6 '/home/u62193446/Week6'; 231 DATA death_count; 232 INFILE '/home/u62193446/Week6/2010-2015-Age65above Final Death Counts.csv' DSD FIRSTOBS = 2; 233 INPUT year month gender $ age ICD10 $ death; 234 RUN; 235 236 * subquery; 237 proc sql; 238 title 'icd10'; 148 TITLE "&category for f1 and f2"; __ 49 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. 239 select ICD10 , death 240 from Work.death_count; 241 where ICD10 = 242 (select ICD10 from Work.death_count 243 where ICD10 = "52"); 244 quit; 245 246 247 248 proc sgplot data=WORK.DEATH_COUNT; 249 histogram death /; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. 250 yaxis grid; 251 run; 252 *------------------------------------------------------------------------------------------------------------------------ 252 ! ----------------------------------; 253 254 *2.5Create a vertical box plot for the death with category =gender.; 255 PROC SGPLOT DATA = death_count; 256 VBOX death/ CATEGORY = gender; 257 TITLE 'Vertical Boxplot Death by Gender'; 258 RUN; 259 *------------------------------------------------------------------------------------------------------------------------ 259 ! ----------------------------------; 260 261 *2.6Create a horizontal box plot for the death with category =month. Save the graph as; 262 *‘Boxplot death by month.png’.; 263 264 265 * Create box plot; 266 ODS LISTING GPATH ='/home/u62193446/Week6'; 267 ODS GRAPHICS / RESET 268 IMAGENAME = 'Boxplot death by Month' 269 OUTPUTFMT = PNG 270 HEIGHT = 3IN WIDTH = 6IN; 271 272 PROC SGPLOT DATA = death_count; 273 HBOX death/ CATEGORY = month; 274 TITLE 'Horizontal Boxplot Death by Month'; 275 RUN; 276 277 278 *######################################################################################################################## 278 ! ##################################; 279 280 281 282 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 283 ODS HTML CLOSE; 284 &GRAPHTERM; ;*';*";*/;RUN;QUIT; 285 QUIT;RUN; 286 ODS HTML5 (ID=WEB) CLOSE; 287 288 FILENAME _GSFNAME; 289 DATA _NULL_; 290 RUN; 291 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK; 292 User: u62193446 Messages: 3
... View more