/****************************************************************************** * Programme : Erstellung einer Gradientenkarte der Vereinigten Staaten * Reference : ERSTELC79D * Source : https://www.wearecas.eu/de/sampleCode/ERSTELC79D ******************************************************************************/ /* --- BLOC 1 --- */ data work.scoreperstate; length state_fips $2.; input state_fips $ _Score_ numeric; datalines; 01 700 02 650 04 720 05 680 06 750 08 690 09 710 10 730 11 670 12 700 13 740 16 680 17 720 18 700 19 690 20 730 21 710 22 700 23 680 24 720 25 710 26 700 27 690 28 730 29 700 30 680 31 720 32 710 33 700 34 690 35 730 36 710 37 700 38 680 39 720 40 710 41 700 42 690 44 730 45 710 46 700 47 680 48 720 49 710 50 700 51 690 53 730 54 710 55 700 56 680 ; run; /* --- BLOC 2 --- */ data states; set maps.states; if state ^in(2,15,72); /* Exclut l'Alaska, Hawaï et Porto Rico */ x = -x * 45/atan(1); /* Conversion de la longitude en degrés */ y = y * 45/atan(1); /* Conversion de la latitude en degrés */ run; /* --- BLOC 3 --- */ data plot_data; set maps.uscenter; if state ^in(2,15,72) and ocean^='Y'; long = -long; statename = fipstate(state); /* Récupère le code FIPS de l'état */ state_fips = put(state, z2.); /* Crée une variable state_fips à partir de 'state' pour la jointure */ run; /* --- BLOC 4 --- */ title 'Average Credit Score in Each State'; footnote4 'Map only includes the lower 48 states in the United States'; /* --- BLOC 5 --- */ proc sgmap mapdata=work.states maprespdata=work.scoreperstate /* Utilisation du jeu de données autonome */ plotdata=work.plot_data; esrimap url='http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Light_Gray_Base'; choromap _Score_ / mapid=state id=state_fips /* Utilisation de state_fips pour la jointure */ density=1 numlevels=4 leveltype=none colormodel=( sty greenyellow deepskyblue cornflowerblue beige) name='choro'; text x=long y=lat text=statename / textattrs=(size=6pt); gradlegend 'choro' / title='Average Credit Score' extractscale; run; quit;