Effekten af statsskovenes overgang til naturnær drift på kulstofbinding i skovene

LIBNAME datalib 'C:\andreas\SL\Projekter\NS-Karbon-2004\Data\Bevliste_2004';
LIBNAME resltlib 'C:\andreas\SL\Projekter\NS-Karbon-2004\Data\Results';
/******************/
/* Carbon model */
/******************/

/******************/
/* Husk at importere Omdrifter */
/******************/

/******************/
/* Scenariovariabler */
/******************/
*naturnær drift;
%LET nnd = 11;
/* 0 = BAU */
/* 1 = omdriftsforlængelse */
/* 2 = træartsskifte */
/* 3 = vedværende skovdække, naturforyngelse nål */
/* 4 = ekstensive foryngelser */
/* 5 = åbne arealer */
/* 6 = pyntegrønt til skov */
/* 7 = dødt ved */
/* 8 = urørt skov */
/* 9 = hugststyrke nål */
/* 10 = naturnær skovdrift */
/* 11 = naturnær skovdrift + storm */

/******************/
/* Vedmassefremskrivning */
/******************/
*korrigering af salgbar masse til total masse;
%LET volkorr = 1.03;
/****************************************
* Macro taucalc                         *
* September 2001 Vivian Kvist Johannsen *
****************************************/
%MACRO taucalc (pk=, v1=, v2=, v3=, v4=,
                p1=, p2=, p3=, p4=, age=);
                   %* beregner stående vedmasse;
*  Vhap = 1/(&v1+&v2*exp(-&v3*&age))+&v4;
                   %* tilvækst over år;
                   %* beregnes ud fra forskel i total produktion ;
  totp1 = 1/(&p1+&p2*exp(-&p3*(&age)))+&p4;
  totp2 = 1/(&p1+&p2*exp(-&p3*(&age+5)))+&p4;
  Iha = totp2 - totp1;
%MEND taucalc;

data blin;
set datalib.bl2004;

*if distrikt_nr = 65;
*if id='60_2_201_542_b'; /*BØG*/
*if id='60_2_201_321_c'; /*RGR*/
*if rejst ne 1;

indaar = 2003;
indalder = alder;
indbpct = bpct;

/* Træart og PK til UKU */
if anv='UKU' then do;
found = 0;
  DO n3=1 TO numobs3 UNTIL (found);
     SET datalib.skovarter (RENAME=(artgrp=skovartgrp anv=skovanv distrikt_nr=dist skovpart_nr=skp skov_nr=skov pk=skovpk pkkl=skovpkkl)) NOBS=numobs3 POINT=n3;
         IF distrikt_nr=dist & skovpart_nr=skp & skov_nr=skov THEN DO;
		 found = 1;
		 anv = skovanv;
		 artgrp = skovartgrp;
		 pk = skovpk;
		 pkkl = skovpkkl;
		 END;
  END;
alder = 2;
if artgrp > 5 then alder = 4;
end;

keep id distrikt_nr indaar areal indbpct anv indalder ipct pk masse_ialt masse__ha fy_1 uroert artgrp pkkl;
run;
data blout blin;
modify blin;
set blin;

tvo = "XXX";
afdrevet = 0;
skaerm = 0;
fy_vent = 0;

aar = indaar;
alder = indalder;
bpct = indbpct;

/* Urørt skov */
if (&nnd=8 OR &nnd>9) & alder>100 then do;
	rand = ranuni(0);
	if artgrp<6 & rand<=0.17 then uroert = 1;
	if artgrp>5 & rand<=0.35 then uroert = 1;
	end;

/* Åbne arealer */
aaben = 0;
if (&nnd=5 OR &nnd>9) & (artgrp=6 OR artgrp=9 OR anv='OMO') & uroert=. then do;
	rand = ranuni(0);
	if artgrp=6 & pkkl=1 & rand<=0.18 then aaben = 1;
	if artgrp=9 & pkkl=1 & rand<=0.40 then aaben = 1;
	if anv='OMO' then aaben = 1;
	end;

/* Artsskifte */
artsskifte = 0;
if (&nnd=2 OR &nnd=3 OR &nnd>9) & (artgrp=6 OR artgrp=7 OR artgrp=9) 
	& aaben=0 & uroert=. then do;
	rand = ranuni(0);
	if artgrp=6 & pkkl=1 & rand<=0.60 then artsskifte = 1;
	if artgrp=6 & pkkl=2 & rand<=0.55 then artsskifte = 1;
	if artgrp=6 & pkkl=3 & rand<=0.50 then artsskifte = 1;
	if artgrp=7 & pkkl=1 & rand<=0.36 then artsskifte = 1;
	if artgrp=7 & pkkl=2 & rand<=0.30 then artsskifte = 1;
	if artgrp=7 & pkkl=3 & rand<=0.30 then artsskifte = 1;
	if artgrp=9 & pkkl=1 & rand<=0.60 then artsskifte = 1;
	if artgrp=9 & pkkl=2 & rand<=0.55 then artsskifte = 1;
	if artgrp=9 & pkkl=3 & rand<=0.50 then artsskifte = 1;
	end; /* artsskifte */

/* aar 2003 (indaar) */
vha = masse__ha;
if vha<0 then vha = 0; /* unge bevoksninger med vha < 0 */
vtot = vha * areal * &volkorr;
if ipct<1 then vtot = masse_ialt; /* Rang I, O, I% = 0 */
vtothugst = 0;
if vtot>0 OR vtothugst>0 then output blout;

/******************/
/* Period loop	  */
/******************/
if indaar=2003 then indaar = indaar + 1;
do aar=indaar to 2104 by 5;
if aar>indaar then alder = alder + 5;
vtothugst = 0;
/******************/
/* Afdrift& Genkultivering */
/******************/
if uroert=. then do;

/* Find passende omdriftsalder */
if aar=indaar OR afdrevet=1 then do;
found = 0;
omdnnd = 0;
if &nnd=1 OR &nnd>9 then omdnnd = 1;
omdart = anv;
if anv="ØSF" then omdart = "SKF";
if anv="FBF" then omdart = "BJF";
  DO n=1 TO numobs UNTIL (found);
     SET resltlib.omdrifter (RENAME=(artgrp=omdartgrp anv=omdanv)) NOBS=numobs POINT=n;
		 artcheck = 1;
		 if artgrp=9 & omdanv ne omdart then artcheck = 0;
         IF artgrp=omdartgrp & naturnaer=omdnnd & artcheck=1 THEN DO;
		 found = 1;
		 if pkkl=1 then omdalder = od_lav;
		 if pkkl=2 then omdalder = od_mid;
		 if pkkl=3 then omdalder = od_god;
		 END;
  END;

if (&nnd=0) & artgrp=8 then do;
	if anv="NGR" then do;
		omdalder = 30;
		if indalder>30 then omdalder = 80;
		end;
	if anv="NOB" then omdalder = 60;
	end;
/* Konvertering PYN->skov */
if (&nnd=6 OR &nnd>9) & artgrp=8 then do;
	rand = ranuni(0);
	if anv="NGR" & rand<=0.21 then omdalder = 30;
	if anv="NOB" & rand<=0.44 then omdalder = 60;
	end;

end; /* if aar=indaar OR afdrevet=1 */

/* Marker til afdrift */
if aaben=0 then afdrevet = 0;
if alder>=omdalder then do;
	afdrevet = 1;
	omd_overstand = 1.3;
	if artgrp<3 then omd_overstand = 1.8;
	if ipct<1 & alderomdalder */

/* Stormfald */
stormfald = 0;
if (&nnd=11) & (aar=2009 OR 
				aar=2019 OR 
				aar=2029 OR 
				aar=2039 OR 
				aar=2049 OR 
				aar=2059 OR 
				aar=2069 OR 
				aar=2079 OR 
				aar=2089 OR 
				aar=2099)
				& artgrp>5 then do;
	rand = ranuni(0);
	if alder>=0.65*omdalder & rand<=0.1 then do;
		afdrevet = 1;
		stormfald = 1;
		end;
	end;

end; /* if uroert=.*/

if aar>indaar then do;
/******************/
/* Tilvækst */
/******************/
/* Find passende tilvækstoversigt */
if aar=indaar+5 OR afdrevet=1 then do;
blartgrp = artgrp;
if artgrp = 5 then blartgrp = 1;
if artgrp = 10 then blartgrp = 6;

tvo = "";
if blartgrp = 6 then do;
	tvo = 'CMM';
	if pk<12 then tvo = 'GWN';
	if distrikt_nr = 21 & anv = 'RGR' then tvo = 'SMA';
	end;

found = 0;
  DO n2=1 TO numobs2 UNTIL (found);
     SET resltlib.tvo4 (RENAME=(artgrp=tvoartgrp tvo=tvotvo)) NOBS=numobs2 POINT=n2;
	 	if blartgrp ne 6 AND blartgrp ne 10 then tvotvo='';
         IF blartgrp=tvoartgrp AND tvo=tvotvo AND pkb le pk AND pkt ge pk THEN DO;
           found = 1;
     END;
  END;
end;

/* Beregn tilvækst */
*Vhax=.; 
Ihax=.;
testt = 0;

tvoalder = alder - 5;
IF tvoalder < minage THEN DO;
   tvoalder = minage;
   testt = 1;
END;
IF tvoalder > maxage THEN DO; 
   tvoalder = maxage;
END;

%taucalc (pk=pk, v1=vt1, v2=vt2, v3=vt3, v4=vt4,
          p1=pt1, p2=pt2, p3=pt3, p4=pt4, age=tvoalder);
*Vhat=Vhap;
*IF Vhat < 0 THEN Vhat = 0;
Ihat = Iha;
IF Ihat < 0 THEN Ihat = 0;

%taucalc (pk=pk, v1=vb1, v2=vb2, v3=vb3, v4=vb4,
          p1=pb1, p2=pb2, p3=pb3, p4=pb4, age=tvoalder);
*Vhab=Vhap;
*IF Vhab < 0 THEN Vhab = 0;
Ihab = Iha;
IF Ihab < 0 THEN Ihab = 0;

*if pk-values inside tvo range;
IF pkt NE 100 AND pkb NE 0 THEN DO;
*  Vhax = Vhat - (Vhat - Vhab)*((pkt-pk)/(pkt-pkb));
  Ihax = Ihat - (Ihat - Ihab)*((pkt-pk)/(pkt-pkb));
  END; 
  ELSE DO;
  *if pk-values below tvo range - use min pk;
  IF pkb = 0 THEN DO;
*     Vhax = Vhat; 
     Ihax = Ihat;
  END;
  *if pk-values above tvo range - use max pk;
  IF pkt = 100 THEN DO;
*     Vhax = Vhab; 
	 Ihax = Ihab;
  END;
END;

IF testt = 1 THEN DO;
	plt = 4;
	if artgrp < 6 then plt = 2;
*	Vhax = Vhax * (alder - plt) / (minage-plt);  
	Ihax = Ihax * (alder - plt) / (minage-plt);  
END;

*if aar=2004 then vhatvo = Vhax * bpct/100 * ipct/100;

ivha = Ihax * bpct/100 * ipct/100; /*dvs. ingen tilvækst og hugst, hvis I%=0*/
if fy_vent>0 then ivha = 0;
if aaben=1 & afdrevet=1 then ivha = 0;
vha = vha + ivha;

/******************/
/* Skærmafvikling */
/******************/
if ipct>0 & uroert=.
	& (artgrp=1 OR
	(&nnd=3 OR &nnd>9) & artsskifte=0 & (artgrp=6 OR artgrp=7 OR artgrp=8 OR artgrp=10) & aaben=0 & stormfald=0) 
	then do;
	if (alder>=omdalder-20 & alder0 then skaerm = 0;
	end;
if skaerm=1 then do;
	vtyndha = vha * (1/(1+ceil((omdalder-alder)/5))) - 0.60 * ivha;
	vha = vha - vtyndha;
	vtothugst = vtothugst + (vtyndha * areal * &volkorr);
	bpct = bpct * (1 - 1/(1+ceil((omdalder-alder)/5)));
	end;
/* Etablering af naturlig foryngelse */
/******************/
if skaerm=1 & (alder>=omdalder-15 & alder0.2*omdalder then do;
vtyndha = 0.60 * ivha;
if (&nnd=9 OR &nnd>9) & artgrp>5 then vtyndha = 0.80 * ivha;
vha = vha - vtyndha;
vtothugst = vtothugst + (vtyndha * areal * &volkorr);
end;

end; /* if aar>indaar */

/* total vedmasse */
if ipct>0 then vtot = vha * areal * &volkorr; /* Ingen opdatering for I%=0 */

/******************/
/* Afdrift& Genkultivering */
/******************/
if afdrevet = 1 then do;

/* Afdrift */
/******************/
if (&nnd=7 OR &nnd>9) OR artgrp<6 then do;
	/* Efterlad dødt ved */
	if skaerm=0 then do;
		vtothugst = vtot * 0.96;
		vha = vha * 0.04;
		vtot = vtot * 0.04;
		end;
	if skaerm=2 then do;
		vtothugst = vtot * 0.84;
		vha = vha * 0.16;
		vtot = vtot * 0.16;
		end;
	end;
	else do;
	vtothugst = vtot;
	vha = 0;
	vtot = 0;
	end;

/* Genkultivering efter renafdrift */
/******************/
/* ekstensive foryngelser */
if (&nnd=4 OR &nnd>9) & ((artgrp=9 & pkkl>1) OR (artgrp=6 & pkkl=1)) 
	& artsskifte=0 & aaben=0 then do;
	if fy_vent>0 then fy_vent = fy_vent - 1;
	if fy_vent=0 then fy_vent = 2;
	end;

if ipct>0 & skaerm=0 & fy_vent=0 & aaben=0 then do; /* ingen genkultivering for ipct=0 eller skærm */
/* artsskifte */
if artsskifte=1 & (&nnd=2 OR &nnd>9) then do;
	rand = ranuni(0);
	if artgrp=6 & pkkl=1 then do;
		if rand<0.67 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 0.65;
			end;
		if rand>=0.67 & rand<0.83 then do;
			artgrp = 3;
			anv = "ASK";
			pk = pk * 0.40;
			end;
		if rand>=0.83 then do;
			artgrp = 4;
			anv = "ÆR";
			pk = pk * 0.62;
			end;
		end;
	if artgrp=6 & pkkl=2 then do;
		if rand<0.82 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 0.65;
			end;
		if rand>=0.82 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 0.40;
			end;
		end;
	if artgrp=6 & pkkl=3 then do;
		if rand<0.50 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 0.40;
			end;
		if rand>=0.50 then do;
			artgrp = 5;
			anv = "ALØ";
			pk = pk * 0.36;
			end;
		end;
	if artgrp=7 & pkkl=1 then do;
		if rand<0.28 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 0.80;
			end;
		if rand>=0.28 & rand<0.56 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 0.49;
			end;
		if rand>=0.56 & rand<0.78 then do;
			artgrp = 3;
			anv = "ASK";
			pk = pk * 0.49;
			end;
		if rand>=0.78 then do;
			artgrp = 4;
			anv = "ÆR";
			pk = pk * 0.76;
			end;
		end;
	if artgrp=7 & pkkl=2 then do;
		if rand<0.33 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 0.80;
			end;
		if rand>=0.33 & rand<0.83 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 0.49;
			end;
		if rand>=0.83 then do;
			artgrp = 5;
			anv = "ALØ";
			pk = pk * 0.44;
			end;
		end;
	if artgrp=7 & pkkl=3 then do;
		if rand<0.50 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 0.49;
			end;
		if rand>=0.50 then do;
			artgrp = 5;
			anv = "ALØ";
			pk = pk * 0.44;
			end;
		end;
	if artgrp=9 & pkkl=1 then do;
		if rand<0.67 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 1.8;
			end;
		if rand>=0.67 & rand<0.83 then do;
			artgrp = 3;
			anv = "ASK";
			pk = pk * 1.1;
			end;
		if rand>=0.83 then do;
			artgrp = 4;
			anv = "ÆR";
			pk = pk * 1.7;
			end;
		end;
	if artgrp=9 & pkkl=2 then do;
		if rand<0.82 then do;
			artgrp = 1;
			anv = "BØG";
			pk = pk * 1.8;
			end;
		if rand>=0.82 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 1.1;
			end;
		end;
	if artgrp=9 & pkkl=3 then do;
		if rand<0.50 then do;
			artgrp = 2;
			anv = "EG";
			pk = pk * 1.1;
			end;
		if rand>=0.50 then do;
			artgrp = 5;
			anv = "ALØ";
			pk = pk *1.0;
			end;
		end;
	end; /* artsskifte */
*pkkl = ...; /* samme som før */
alder = 2;
if artgrp > 5 then alder = 4;
end; /* if ipct>0, genkulitvering */

end; /* if afdrevet=1, afdrift */

if vtot>0 OR vtothugst>0 then output blout;
if skaerm=1 & afdrevet=1 then aar=9999;
end; /* aar-loop */

keep artgrp aar vtot vtothugst stormfald;
*keep artgrp aar vtot vtothugst areal ipct;
run;

data vstorm;
set blout;
if stormfald=1;
drop stormfald;
run;
proc sort data=vstorm;
by aar;
run;
proc means data=vstorm noprint;
by aar;
var vtothugst;
output out=resltlib.vstormsum
sum(vtothugst)= vstorm
;
run;
data resltlib.vstormsum;
set resltlib.vstormsum;
vstorm = vstorm / 1000000;
run;

data blout;
set blout;
drop stormfald;
run;
proc sort data=blout;
by artgrp aar;
run;
proc means data=blout noprint;
by artgrp aar;
var vtot vtothugst;
output out=resltlib.vbyart
sum(vtot)=sum_vtot
sum(vtothugst)=sum_vtothugst
;
run;

/******************/
/* Expansion fra vedmasse til karbon */
/******************/
/****************************************
* Variables used for Carbon stock calc. *
****************************************/
*kulstofindhold tC/t totalmasse;
%LET Cforhold = 0.5;
*Ekspansionsfaktor t totalmasse/t stammemasse;
%LET LOVekspa = 1.2;
%LET NALekspa = 1.8;
*Fastmasse t toerstof / m3 frisk volumen;
%LET CRGR = 0.38;
%LET CSGR = 0.37;
%LET CEGR = 0.38;
%LET CANN = 0.43;

%LET CBOG = 0.56;
%LET CEG  = 0.57;
%LET CASK = 0.56;
%LET CER  = 0.49;
%LET CANL = 0.56;
data resltlib.vbyart;
set resltlib.vbyart;

v = sum_vtot / 1000000;

/* Løv */
if artgrp < 6 then do;
  c = v * &LOVekspa * &Cforhold * 3.67;

  if artgrp = 1 then c = c * &CBOG;
  if artgrp = 2 then c = c * &CEG;
  if artgrp = 3 then c = c * &CASK;
  if artgrp = 4 then c = c * &CER;
  if artgrp = 5 then c = c * &CANL;
end;
/* Nål */
	else do;
  c = v * &NALekspa * &Cforhold * 3.67;

  if artgrp = 6 then c = c * &CRGR;
  if artgrp = 7 then c = c * &CSGR;
  if artgrp = 8 then c = c * &CEGR;
  if artgrp = 9 then c = c * &CANN;
  if artgrp = 10 then c = c * &CANN;
end;

run;
data resltlib.vbyart;
set resltlib.vbyart;

vh = sum_vtothugst / 1000000;
if aar ne 2004 then vh = vh / 5;

pv = lag1(v);
pc = lag1(c);
if artgrp=lag1(artgrp) & aar ne 2004 then do;
iv = (v - pv)/5;
ic = (c - pc)/5;
end;
keep artgrp aar v c iv ic vh;
run;
proc sort data=resltlib.vbyart;
by aar;
run;
proc means data=resltlib.vbyart noprint;
by aar;
var v c iv ic vh;
output out=resltlib.vsum
sum(v c iv ic vh)=v c iv ic vh
;
run;
data vsumcor;
set resltlib.vsum;
if aar>2003;
run;
proc means data=vsumcor noprint;
var v c iv ic vh;
output out=resltlib.vmeans
sum(v c iv ic vh)=v c iv ic vh
;
run;
data resltlib.vmeans;
set resltlib.vmeans;
v = v / 21;
c = c / 21;
iv = iv / 20;
ic = ic / 20;
vh = vh / 21;
period = "2004-2104";
run;
data icperiods;
set resltlib.vsum;
if aar>2004;
if aar <2039 then period = "2004-2034";
if aar >2034 then period = "2034-2104";
run;
proc means data=icperiods noprint;
by period;
output out=icperiodsmeans
mean(v c iv ic vh)=v c iv ic vh
;
run;
data resltlib.vmeans;
merge resltlib.vmeans icperiodsmeans;
by period;
run;
data icperiods;
set resltlib.vsum;
if aar=2014;
period = "2009-2014";
keep period ic iv vh;
run;
data resltlib.vmeans;
merge resltlib.vmeans icperiods;
by period;
drop _type_ _freq_;
run;

/******************/
/* Grafer */
/******************/
data plotdata0;
set resltlib.vbyart;
if artgrp ne .;
if artgrp = 3 then artgrp = 5;
if artgrp = 4 then artgrp = 5;
if artgrp = 8 then artgrp = 10;
keep aar artgrp v c iv ic vh;
run;
proc sort data= plotdata0;
by artgrp aar;
run;
proc means data=plotdata0 noprint;
by artgrp aar;
var v c vh iv ic;
output out=plotdata
sum(v)=v
sum(c)=c
sum(vh)=vh
sum(ic)=ic
sum(iv)=iv
;
run;
data plotdata;
set plotdata;
if artgrp=6 then rank=1;
if artgrp=1 then rank=2;
if artgrp=9 then rank=3;
if artgrp=10 then rank=4;
if artgrp=7 then rank=5;
if artgrp=2 then rank=6;
if artgrp=5 then rank=7;
run;
proc sort data= plotdata;
by aar rank;
run;
data plotdata;
set plotdata;
ccum = ccum + c;
vcum = vcum + v;
vhcum = vhcum + vh;
iccum = iccum + ic;
ivcum = ivcum + iv;
if aar ne lag1(aar) then do;
	ccum = c;
	vcum = v;
	vhcum = vh;
	iccum = ic;
	ivcum = iv;
end;
iaar = aar-2.5;
staar = aar;
if staar = 2004 then staar = 2005;
if staar = 2003 then staar = 2004;
output;
if rank=7 then do;
rank = 8;
artgrp = 11;
iv = ivcum;
ic = iccum;
ccum = .;
vcum = .;
vhcum = .;
output;
end;
retain ccum vcum vhcum;
retain iccum ivcum;
run;

/* Husk at køre Danish-letters */
PROC GREPLAY igout=GSEG tc=tempcat nofs;
   DELETE _ALL_ ;
run;
goptions reset=all;
goptions
htext = 10 pt
vsize = 8 cm
hsize = 8 cm
gunit = pct
;
goptions keymap=mykeymap;
GOPTIONS DEVICE=CGMMW6C
         GSFMODE=REPLACE
         GSFLEN=80
		 FTEXT = simplex
		 NOPROMPT
		 GSFNAME=graph
;
filename graph 'C:\andreas\SL\Projekter\NS-Karbon-2004\Data\Results\scenario_11a';
proc gplot data=plotdata;

axis1 
label=(angle = 90 'Stående vedmasse (Mio. m3)')
order=0 to 40 by 5 
value=(height=8pt) 
major=(h=4pt) minor=none
offset=(0,0)
;

axis11 
label=(angle = 90 'Bundet kulstof (Mio. to CO2)')
order=0 to 50 by 5 
value=(height=8pt) 
major=(h=4pt) minor=none
offset=(0,0)
;

axis14
label=(angle = 90 'Hugst (Mio. m3/år)')
order=0 to 1.2 by 0.2 
value=(height=8pt) 
major=(h=4pt) minor=none
offset=(0,0)
;

axis2 
label=('År')
order=2004 to 2104 by 20 
value=(height=8pt) 
major=(h=2pt) minor=none
offset=(5)pct
;

symbol1 I=join V=none C=black;
symbol2 I=join V=none C=black;
symbol3 I=join V=none C=black;
symbol4 I=join V=none C=black;
symbol5 I=join V=none C=black;
symbol6 I=join V=none C=black;
symbol7 I=join V=none C=black;
symbol8 I=join V=none C=black;

pattern1 V=solid C=black;
pattern2 V=SOLID C=GRAY9D;
pattern3 V=EMPTY C=black;
pattern4 V=M1N45 C=black;
pattern5 V=M1N135 C=black;
pattern6 V=M1N0 C=black;
pattern7 V=M1X45 C=black;
pattern8 V=M1X0 C=black;
*pattern9 V=M3N45 C=black;
*pattern10 V=M3N135 C=black;

plot vcum * staar = rank /vaxis=axis1 haxis=axis2 areas=8 nolegend name='vdyn';
plot ccum * staar = rank /vaxis=axis11 haxis=axis2 areas=8 nolegend name='cdyn';
plot vhcum * aar = rank /vaxis=axis14 haxis=axis2 areas=8 nolegend name='vhdyn';

run;
proc sort data= plotdata;
by aar artgrp;
run;
proc gplot data=plotdata;

axis12
label=(angle = 90 'Nettovedmassetilvækst (Mio. m3/år)')
order=-0.2 to 0.6 by 0.1 
value=(height=8pt) 
major=(h=4pt) minor=none
offset=(0,0)
;

axis13 
label=(angle = 90 'Nettokulstofbinding (Mio. to CO2/år)')
order=-0.3 to 0.7 by 0.1 
value=(height=8pt) 
major=(h=4pt) minor=none
offset=(0,0)
;

axis2 
label=('År')
order=2004 to 2104 by 20 
value=(height=8pt) 
major=(h=2pt) minor=none
offset=(5)pct
;

symbol1 I=join V=circle h=6pt L=1 W=10 C=black;
symbol2 I=join V=circle h=6pt L=1 W=1 C=black;
symbol3 I=join V=circle h=6pt L=4 W=1 C=black;
symbol4 I=join V=triangle h=6pt L=1 W=10 C=black;
symbol5 I=join V=triangle h=6pt L=1 W=1 C=black;
symbol6 I=join V=triangle h=6pt L=2 W=1 C=black;
symbol7 I=join V=triangle h=6pt L=4 W=1 C=black;
symbol8 I=join V=none L=1 W=40 C=black;

plot iv * iaar = artgrp /vaxis=axis12 haxis=axis2 nolegend vref=0 name='ivdyn';
plot ic * iaar = artgrp /vaxis=axis13 haxis=axis2 nolegend vref=0 0.183 lvref=(1 2) name='icdyn';

run;
quit;

/* Legends */
data legend;
length function color $8 text $25;
retain hsys xsys ysys '3';

/* Titles */
function='label'; x=50; y=99;  position='6'; color='black'; size=5; angle=0; text='Træart'; output;
function='label'; x=50; y=89;  position='6'; color='black'; size=5; angle=0; text='Andet løv'; output;
function='label'; x=50; y=83;  position='6'; color='black'; size=5; angle=0; text='Eg'; output;
function='label'; x=50; y=77;  position='6'; color='black'; size=5; angle=0; text='Sitkagran'; output;
function='label'; x=50; y=71;  position='6'; color='black'; size=5; angle=0; text='Andet nål'; output;
function='label'; x=50; y=65;  position='6'; color='black'; size=5; angle=0; text='Fyr'; output;
function='label'; x=50; y=59;  position='6'; color='black'; size=5; angle=0; text='Bøg'; output;
function='label'; x=50; y=53;  position='6'; color='black'; size=5; angle=0; text='Rødgran'; output;
function='label'; x=50; y=47;  position='6'; color='black'; size=5; angle=0; text='Alle'; output;

/* Lines */
function='move'; x=75; y=88; output;
function='draw'; x=85; y=88; line=4; color='black'; size=0.01; output;
function='symbol'; x=80; y=88; line=1; color='black'; size=5; text='circle'; output;

function='move'; x=75; y=82; output;
function='draw'; x=85; y=82; line=1; color='black'; size=0.01; output;
function='symbol'; x=80; y=82; line=1; color='black'; size=5; text='circle'; output;

function='move'; x=75; y=76; output;
function='draw'; x=85; y=76; line=1; color='black'; size=0.01; output;
function='symbol'; x=80; y=76; line=1; color='black'; size=5; text='triangle'; output;

function='move'; x=75; y=70; output;
function='draw'; x=85; y=70; line=4; color='black'; size=0.01; output;
function='symbol'; x=80; y=70; line=1; color='black'; size=5; text='triangle'; output;

function='move'; x=75; y=64; output;
function='draw'; x=85; y=64; line=2; color='black'; size=0.01; output;
function='symbol'; x=80; y=64; line=1; color='black'; size=5; text='triangle'; output;

function='move'; x=75; y=58; output;
function='draw'; x=85; y=58; line=1; color='black'; size=0.1; output;
function='symbol'; x=80; y=58; line=1; color='black'; size=5; text='circle'; output;

function='move'; x=75; y=52; output;
function='draw'; x=85; y=52; line=1; color='black'; size=0.1; output;
function='symbol'; x=80; y=52; line=1; color='black'; size=5; text='triangle'; output;

function='move'; x=75; y=46; output;
function='draw'; x=85; y=46; line=1; color='black'; size=0.4; output;

/* Bars */
pattern1 V=solid C=black;
pattern2 V=SOLID C=GRAY9D;
pattern3 V=EMPTY C=black;
pattern4 V=M1N45 C=black;
pattern5 V=M1N135 C=black;
pattern6 V=M1N0 C=black;
pattern7 V=M1X45 C=black;
pattern8 V=M1X0 C=black;
function='move'; x=35; y=90; output;
function='bar'; x=45; y=86; line=0; color='black'; size=5; style='M1X45'; output;

function='move'; x=35; y=84; output;
function='bar'; x=45; y=80; line=0; color='black'; size=5; style='M1N0'; output;

function='move'; x=35; y=78; output;
function='bar'; x=45; y=74; line=0; color='black'; size=5; style='L1'; output;

function='move'; x=35; y=72; output;
function='bar'; x=45; y=68; line=0; color='black'; size=5; style='M1N45'; output;

function='move'; x=35; y=66; output;
function='bar'; x=45; y=62; line=0; color='black'; size=5; style='EMPTY'; output;

function='move'; x=35; y=60; output;
function='bar'; x=45; y=56; line=0; color='GRAY9D'; size=5; style='SOLID'; output;

function='move'; x=35; y=54; output;
function='bar'; x=45; y=50; line=0; color='black'; size=5; style='SOLID'; output;

run;
proc gslide annotate=legend name='LABEL';
Title1 ' ' ;
Footnote1 ' ';
run;

/*Combine 6 graphs into one*/
goptions display VSIZE=20 CM HSIZE=12 CM;
*filename graph 'D:\SL\Projekter\NS-Karbon-2004\Data\Results\grafs\scen00.cgm';
PROC GREPLAY IGOUT=GSEG TC=TEMPCAT NOFS;
TDEF MUCHOS DES='all'

1/LLX=0  LLY=67 ULX=0  ULY=97 URX=50  URY=97 LRX=50  LRY=67
2/LLX=0  LLY=34 ULX=0  ULY=64  URX=50  URY=64  LRX=50  LRY=34
3/LLX=0  LLY=1 ULX=0  ULY=31  URX=50  URY=31  LRX=50  LRY=1

4/LLX=50  LLY=67  ULX=50  ULY=97  URX=100  URY=97  LRX=100  LRY=67
5/LLX=50  LLY=34 ULX=50  ULY=64 URX=100  URY=64 LRX=100  LRY=34
6/LLX=50  LLY=1 ULX=50  ULY=31  URX=100  URY=31  LRX=100  LRY=1
;

TEMPLATE=MUCHOS;
TREPLAY			1:cdyn
				2:vdyn
				3:vhdyn
				4:icdyn
				5:ivdyn
				6:label
				;
run;
quit;

 



Version 1.0 Juli 2005, © Miljøstyrelsen.