remove white space from map when using proc gmap - sas

I'm using the following code in sas:
goptions reset=all border ;
goptions colors=(yellow steel purple pink red blue cyan orange green gray
black);
title1 "Congo";
title2 "11 Regions";
footnote j=r "Congo ";
proc gmap map=mapsgfk.dr_congo data=mapsgfk.dr_congo all density=6;
id id1;
choro id1/discrete;run;
quit;
and it generates the following map:
How do I remove the white space inside some of the regions?

The map data is segmented at the ID level. The ID1 value is a truncation of ID. The 'white-space' is due to a segment being associated to an id it does not belong to. Try:
proc gmap
map=mapsgfk.dr_congo data=mapsgfk.dr_congo all density=6
;
* simpler statements per DCR comment, removed format;
id id;
choro id1 / discrete;
run;
quit;
I believe there may still be some issues regarding lakes being drawn with a color.

Related

How do I change colours of different bars in SAS?

proc sgplot data=WORK.CUSTOMERDATA;
title height=14pt "Bar Chart of Gender";
vbar Gender / fillattrs= (color=CX024ae6) datalabel;
yaxis grid;
run;
ods graphics / reset;
title;
how do I change the colour of individual bars ? I have tried fill= and styleattrs datacolors= but it doesn't seem to work..
Should you wish to have one color for the graduated and another for the ones that did not, the following should provide the desired output
proc sgplot data=customerdata;
title height=14pt "Bar Chart of Graduated";
styleattrs datacolors=(blue red) ;
vbar Graduated / group=Graduated filltype=solid datalabel;
yaxis grid;
run;

SAS - omit missing values on proc tabulate procedure

I need help to omit missing values on proc tabulate procedure. I understand that by right proc tabulate do not calculate missing values. However, when I do not specify /missing on the class variable, the result won't appear and the log shows a warning that says:
WARNING: A class, frequency, or weight variable is missing on every observation.
Below is the proc tabulate step of the dataset:
TITLE j=left "Jadual B1 : Jumlah penduduk mengikut kumpulan etnik, kawasan pihak berkuasa tempa'tan dan negeri, Malaysia, 2010";
Title2 font=bold italic j=left "Table B1 : Total population by ethnic group, local authority area and state, Malaysia, 2010";
title3 " ";
title4 j=left "Negeri : NEGERI SEMBILAN";
title5 font=bold italic j=left "State";
ods escapechar='^';
proc tabulate data=WORK.DOSM order=data ;
class DISTRICT NEW_ETHNICITY NEW_CITIZENSHIP MELAYU BUMI_LAIN CINA INDIA LAIN Bumiputera /missing;
var ID;
table ALL DISTRICT=' ', ALL
NEW_ETHNICITY={LABEL=' '}* (( Bumiputera ={LABEL=' '}* (MELAYU={LABEL=' '}* N
BUMI_LAIN={LABEL=' '} * N ALL) INDIA={LABEL=' '}*N CINA={LABEL=' '}*N LAIN={LABEL=' '} *N ))
NEW_CITIZENSHIP={LABEL=' '}
/Box='Daerah Pentadbiran/Kawasan Pihak Berkuasa Tempatan ^S={font_style=italic}
Administrative District/Local Authority Area' row=float;
keylabel N=' ';
keylabel all='Jumlah ^S={font_style=italic}/ Total';
footnote font=arial bold j=left "Nota" font=arial bold italic "/Note:";
footnote2 j=l f='ARIAL amt/bold' "^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^Angka-angka di atas tidak disesuaikan untuk kurang penghitungan.";
footnote3 j=l font=bold italic "^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^The above figures have not been adjusted for under enumeration.";
run;
And below is my output:
Output
But, I need the result to not show the missing values as per the image red highlighted columns.
You can have multiple CLASS statements. Identify which variable is missing ( I think New_Ethnicity) and move that to a new CLASS statement without the missing option on that variable.
Example based on linked duplicate above.
Multiple CLASS statements appear to work in this case:
data test_cars;
set sashelp.cars;
if _n_=5 then call missing(make);
if _n_=7 then call missing(model);
if _n_=10 then call missing(type);
if _n_=13 then call missing(origin);
run;
proc tabulate data=test_cars out=test_tabulate(rename=n=count);
class make model type /missing;
class origin;
tables (make model type),origin*n;
run;
Thanks #Joe for making sample data ;)

By group controlling line colors/where clause

I want to plot Y by X plot where I group by year, but color code year based on different variable (dry). So each year shows as separate line but dry=1 years plot one color and dry=0 years plot different color. I actually figured one option (yeah!) which is below. But this doesn't give me much control.
Is there a way to put a where clause in the series statement to select specific categories so that I can specifically assign a color (or other format)? Or is there another way? This would be analogous to R where one can use multiple line statements for different subsets of data.
Thanks!!
This code works.
proc sgplot data = tmp;
where microsite_id = "&msit";
by microsite_id ;
yaxis label= "Pct. Stakes" values = (0 to 100 by 20);
xaxis label= 'Date' values = (121 to 288 by 15);
series y=tpctwett x=jday / markers markerattrs=(symbol=plus) group = year grouplc=dry groupmc=dry;
format jday tadjday metajday jdyfmt.;
label tpctwett='%surface water' tadval1='breed' metaval1='meta';
run;
Use an Attribute map, see the documentation
You can use the DRY variable to set the specific colours. For each year, assign the colour using the DRY variable in a data step.
proc sort data=tmp out=attr_data; by year; run;
data attrs;
set attr_data;
id='year';
if dry=0 then linecolor='green';
if dry=1 then linecolor='red';
keep id linecolor;
run;
Then add the dattrmap=attrs in the PROC SGPLOT statement and the attrid=year in the SGPLOT options.
ods graphics / attrpriority=none;
proc sgplot data = tmp dattrmap=attrs;
where microsite_id = "&msit";
by microsite_id ;
yaxis label= "Pct. Stakes" values = (0 to 100 by 20);
xaxis label= 'Date' values = (121 to 288 by 15);
series y=tpctwett x=jday / markers markerattrs=(symbol=plus) group = year grouplc=dry groupmc=dry attrid=year;
format jday tadjday metajday jdyfmt.;
label tpctwett='%surface water' tadval1='breed' metaval1='meta';
run;
Note that I tested and edited this post so it should work now.

Title on only first page

This is my first time using a programming related stack. So if this doesn't belong or should go somewhere please inform me and I will fix it.
I've just begun to use SAS Studio. I believe I have set up a title correctly, but I can't seem to get it only on the first page. It adds the title to every subsequent page I create. I've just begun watching tutorials on the SAS website, but I have yet to run across the answer to this particular question. Can anyone help point me in a correct direction?
Here is my code:
Data Question21;
Input Transfers Broken ##;
Datalines;
1 16 0 9 2 17 0 12 3 22 1 13 0 8 1 15 2 19 0 11
;
title color=red Bold underlin=3 "Assignment #1";
Proc Print;
run;
Proc sgplot;
scatter x=Transfers y=Broken;
run;
Proc reg;
model Broken=Transfers;
run;
and this is a sample of what happens when it runs:
TITLE is a global statement, and will take effect until you turn it off. So the simple answer is: after the PROC in which you want the title, and its RUN statement (or QUIT in those that use quit), enter
title;
Which will then clear all titles.
In a bit more detail:
Titles, and Footnotes, have a set of ten (each) that are in a sort of 'stack' (Setting one removes all higher ones). SAS stores them internally, and any time a PROC or anything else runs that supports a title, it will grab whatever is currently in the title and footnote stacks and show those titles and those footnotes.
It is important to remember that any PROC or DATA step doesn't submit fully until RUN or QUIT is reached, or else another PROC or DATA step is begun (called a "Step Boundary"). Since TITLE is a global statement, what'll happen is whatever is in the current title stack when the step boundary is reached will be shown. Notice what you actually see here...
title "One Title";
proc print data=sashelp.class;
title "Two Title";
run;
title "Three Title";
proc freq data=sashelp.class;
tables sex*age/list;
run;
title "Four";
A good habit is to always put TITLE statements in a consistent place - some disagree over where, but choose either:
Before the PROC/DATA statement
Immediately before RUN
and stick with it. Then, after every RUN, include a TITLE;, unless you intentionally have a common title.
For example, I might have an assignment that is to print SASHELP.CLASS, run some frequencies on it, and use PROC UNIVARIATE to look at the WEIGHT and HEIGHT variables.
title "SAS Class, Assignment One";
title2 "Written By Joe, 9/2/2015"; *these are global titles used for all printing;
title3 "Print of first 10 obs of SASHELP.CLASS";
proc print data=sashelp.class(obs=10);
run;
title3;
title3 "Freq of AGE, SEX in SASHELP.CLASS";
proc freq data=sashelp.class;
tables age sex;
run;
title3;
title3 "Univariate Examination of SASHELP.CLASS";
title4 "HEIGHT variable";
proc univariate data=sashelp.class;
var height;
run;
title4;
title4 "WEIGHT variable";
proc univariate data=sashelp.class;
var weight;
run;
title3; *notice 3 here - ending all of 3;
title3 "Plot of SASHELP.CLASS Height v Weight";
proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;
title; *ends all titles!;

Color options in GPLOT in SAS

I have a temporal series with a variable in the horizontal axis that is the year. Once i have drawn it with gplot procedure I want to divide the graphic in years painting each year in different color. I have tried to do an if statemente inside gplot procedure when defining the color inside symbol options like this
symbol
if year=2006 then c=red;
(this is very simplified, it would depend on much more years and all this stuff)
but this desnt work.
EDITED:
Thanks everybody but I think i didint explain myself properly. I
have this code
PROC GPLOT DATA = work.Datosipppa
;
PLOT IPPPA * date /
OVERLAY
VAXIS=AXIS1
HAXIS=AXIS2
FRAME LEGEND=LEGEND1
href='01jun2006'd '01jun2007'd
;
PLOT2 tasaParoMensual * date = 2 /
OVERLAY
VAXIS=AXIS3
OVERLAY
LEGEND=LEGEND1
;
run;
quit;
and i want to colored each of the years in different colour.
I want to show you my graph but i cant if idont have 10 of reputation :(
IN FACT I WANT TO DO SOMETHNG EQUAL TO THIS EXAMPLE
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#a003259878.htm
BUT INSTEAD OF IN THIS PROCEDURE IN GPLOT
One straightforward approach is to create a list colors in the GOPTIONS statement, like this:
goptions reset=all colors=(red yellow green blue purple black);
symbol value=dot;
proc gplot data=sashelp.cars;
plot horsepower * enginesize = type;
run;
quit;
You will need to review the output carefully that the years match the colors you want.
Another way is to specify separate symbol statements for each group you are plotting. Try this example below that is a stripped down version of your code. You will need to create a YEAR variable and include that in the PLOT statement so each year will be assigned to a different symbol statement / color.
goptions reset=all;
*** GENERATE TEST DATA ***;
data have;
do date = '01Jun2005'd to '01aug2007'd;
ipppa = ranuni(123456);
tasaParoMensual = 10 + rannor(123456) ;
year = year(date);
output;
end;
run;
*** SYMBOLS 1-3 ARE USED IN THE FIRST PLOT STATEMENT TO SYMBOLIZE THE THREE YEARS IN THE DATA ***;
symbol1 value=dot color=red;
symbol2 value=dot color=green;
symbol3 value=dot color=yellow;
*** SYMBOLS 4 IS USED IN THE PLOT2 STATEMENT ***;
symbol4 value=star color=black i=join;
proc gplot data=have;
plot ipppa * date = year /
href='01jun2006'd '01jun2007'd
;
plot2 tasaParoMensual * date ;
run;
quit;
Hope that helps.