I am trying to create a pdf report with ODS containing up to 4 charts per page. The old report was created by Access reports and then printed to pdf.
My goal is to create a report in SAS that looks quite similar to the old one.
At the moment I am still stuck adjusting the width of my charts. Defining width in the "ods graphics" statement causes exceptions.
Is there also a way to define the width of the area left to the charts? So that the bar areas (0% - 100%) are placed directly beneath each other?
proc format;
value alterkl
1 = "15 bis 25 Jahre"
2 = "25 bis 35 Jahre"
3 = "35 bis 45 Jahre"
4 = "45 bis 55 Jahre"
5 = "55 bis 65 Jahre"
6 = "ueber 65 Jahre"
7 = "unbekannt"
8 = "Anzahl Kunden" ;
value anzvt
1 = "Kunden mit 1 Vertrag"
2 = "Kunden mit 2 Vertraegen"
3 = "Kunden mit 3 Vertraegen"
4 = "Kunden mit 4 Vertraegen"
5 = "mehr als 4 Vertraege" ;
quit;
data out_alterkl;
length bd $ 6 alterkl $ 15 alterkl_sort 3 anzahl 8 anteil 8;
infile cards dsd dlm='|' truncover ;
input bd alterkl alterkl_sort anzahl anteil ;
cards;
Gesamt|15 bis 25|1|33532|0.026776524
Gesamt|25 bis 35|2|168160|0.1342818882
Gesamt|35 bis 45|3|191328|0.1527823805
Gesamt|45 bis 55|4|224369|0.179166823
Gesamt|55 bis 65|5|267231|0.213393692
Gesamt|ueber 65|6|260689|0.2081696666
Gesamt|Rest|7|106982|0.0854290257
Gesamt|Anzahl Kunden|8|1252294|.
;
run;
data out_anzvt;
length bd $ 6 anz_vt anzahl 8 anteil 8;
infile cards dsd dlm='|' truncover ;
input bd anz_vt anzahl anteil ;
cards;
Gesamt|1|982757|0.7847672785
Gesamt|2|121707|0.0971874748
Gesamt|3|54379|0.0434236132
Gesamt|4|32905|0.0262758416
Gesamt|5|60543|0.0483457918
;
run;
options orientation=landscape nocenter ;
options leftmargin=.001in rightmargin=.001in topmargin=.001in bottommargin=.001in;
ods pdf file="\\ivvs0042\sas_pu$\sas_dw\PBT_Koeln\Temp\betandsauswertung.pdf" startpage=never;
*ods graphics on / scale=off width=5in outputfmt=pdf ;
ods layout absolute ;
ods region x=0cm y=0cm width=25cm height=10cm style={background=lightgrey} ;
proc sgplot data=out_alterkl nowall noborder ;
where bd = 'Gesamt';
label anzahl='Anzahl' anteil='Anteil' alterkl_sort='Altersstruktur';
format alterkl_sort alterkl. anzahl commax12.0 anteil nlpct8.1;
hbar alterkl_sort / stat=sum response=anteil ;
yaxistable anzahl / stat=sum valueattrs=(weight=bold) nostatlabel position=right ;
yaxis label="Altersstruktur" labelpos=top ;
yaxistable anteil / stat=sum valueattrs=(weight=bold) nostatlabel position=right nomissingchar;
xaxis grid min=0 max=1;
run;
ods region x=0cm y=10cm width=25cm height=10cm style={background=lightblue};
proc sgplot data=out_anzvt nowall noborder ;
where bd = 'Gesamt';
label anzahl='Anzahl' anteil='Anteil' anz_vt='Vertragsdichte';
format anz_vt anzvt. anzahl commax12.0 anteil nlpct8.1;
hbar anz_vt / stat=sum response=anteil ;
yaxistable anzahl / stat=sum valueattrs=(weight=bold) nostatlabel position=right ;
yaxis label="Vertragsdichte" labelpos=top ;
yaxistable anteil / stat=sum valueattrs=(weight=bold) nostatlabel position=right nomissingchar;
xaxis grid min=0 max=1;
run;
ods layout end;
ods pdf close;
I hope someone could help me.
Christoph
Related
I have a netcdf data file with the following variables shown in the ncdump snippet below:
netcdf elev.0.5-deg {
dimensions:
lat = 360 ;
lon = 720 ;
time = UNLIMITED ; // (1 currently)
variables:
float lat(lat) ;
lat:title = "Latitude" ;
lat:units = "degrees_north" ;
lat:scale_factor = 1.f ;
lat:add_offset = 0.f ;
float lon(lon) ;
lon:title = "Longitude" ;
lon:units = "degrees_east" ;
lon:scale_factor = 1.f ;
lon:add_offset = 0.f ;
double time(time) ;
time:title = "Time" ;
time:units = "hours since 1-1-1 0:0:0" ;
time:scale_factor = 1.f ;
time:add_offset = 0.f ;
short data(time, lat, lon) ;
data:long_name = "meters, from 5-min data" ;
data:add_offset = 0.f ;
data:scale_factor = 1.f ;
data:missing_value = 32767s ;
data:units = "meters, from 5-min data" ;
I am trying to eliminate the time coordinate variable from this file in order to get a 3 dimensional netcdf data file. Basically having data the data values for the first time in the netcdf files and that is all. I have tried to accomplish this with ncks which is what they showed I should do when doing a google search. I tried the following command with ncks:
ncks -x -v time elev.0.5-deg.nc test.nc
but I cannot get the time dimension removed. What should I be doing to tweak this command to get the desired results of showing the data for just the initial time step and only having dimensions lat and lon in test.nc?
Use ncwa
ncwa -a time in.nc out.nc
You should be able to do this using CDO:
cdo --reduce_dim -copy elev.0.5-deg.nc test.nc
I am modeling a production problem in AMPL with start and end inventories to be zero.
Simple 3 products being produced over 4 day span, on a single machine.
however my model keeps having problems with the bigM constraint and no inventory is allocated.Model is infeasible per AMPL presolve.
I would really appreciate if someone could point whats wrong or what i should try. Thanks in advance!
HERE IS THE CODE -
param n;
param m;
param M;
param T;
set I := {1..n};
set J := {1..m};
param r {I} integer; #productionrate
param stp {I} integer; #setuptime
param rev {I} integer; #sellingprice
param h {I} integer; #inventorycost
param d {I,J} integer; #demand
var t {I,J} integer >= 0, <=480 default 50; #production time allocated for product i on day j
var s {I,J} integer >= 0 default 50; #inventory of product i on day j
var z {I,J} binary default 1; #setup for product i done on day j or not
#sum of revenue - sum of inventory cost
maximize K: sum {i in I,j in J}(rev[i] * t[i,j] * r[i] * z[i,j]) - sum {i in I,j in J}(h[i] * s[i,j]);
#inventory equation
s.t. c2 {i in I,j in 2..4}: s[i,j] = s[i,j-1] + t[i,j]*r[i] - d[i,j];
s.t. c14 {i in I}: s[i,1] = t[i,1]*r[i] - d[i,1];
#initial and end inventories
s.t. c3 {i in I}: s[i,1] = 0;
s.t. c4 {i in I}: s[i,4] = 0;
#ensuring time allocation only when setup
s.t. c5 {i in I,j in J}: t[i,j] <= M*z[i,j];
#ensuring demand is satisfied
s.t. c6 {i in I,j in 2..4}: s[i,j-1] + t[i,j]*r[i] = d[i,j];
s.t. c11 {i in I}: t[i,1]*r[i] = d[i,1];
#production time constraint
s.t. c7 {j in J}: sum{i in I}(z[i,j]*stp[i]) + sum{i in I}(t[i,j]) <= T;
#other non-negativity constraints
s.t. c12 {i in I,j in J}: s[i,j] >= 0;
#s.t. c13 {i in I,j in J}: t[i,j] >= 0;
end;
HERE IS THE DATA -
param n :=3;
param m :=4;
param T :=480;
param M :=480;
#param o :=2;
param d: 1 2 3 4 :=
1 400 600 200 800
2 240 440 100 660
3 80 120 40 100;
param r:=
1 5
2 4
3 2;
param stp:=
1 45
2 60
3 100;
param rev:=
1 50
2 70
3 120;
param h:=
1 2
2 1
3 3;
end;
RUN FILE -
#RESET THE AMPL ENVIROMENT
reset;
#LOAD THE MODEL
model 'EDX 15.053 Production problem.mod';
#LOAD THE DATA
data 'EDX 15.053 Production problem.dat';
#DISPLAY THE PROBLEM FORMULATION
expand K;
expand c2;
#expand c3;
expand c4;
expand c5;
expand c6;
expand c7;
expand c11;
#let s[3,3] := 20;
#CHANGE THE SOLVER (optional)
#option solver CBC;
option solver cplex, cplex_options ’presolve 0’;
option show_stats 1;
option send_statuses 0;
#option presolve 0;
#SOLVE
solve;
print {j in 1.._nvars:_var[j].status = "pre"}: _varname[j];
print {i in 1.._ncons:_con[i].status = "pre"}: _conname[i];
display solve_message;
display solve_result_num, solve_result;
#SHOW RESULTS
display t,s,z,K;
end;
Error when loading data into Postgres table from SAS(Invalid input syntax for integer)
I am using SAS Data Integration Studio with SCD Type 1 loader to load data into PostGres Table.
First of all, the issue that I am facing is the error message:
ERROR: CLI execute error: ERROR: invalid input syntax for integer: "1372.8"; Error while executing the query
I've searched the entire table(170 rows) and there is no data with the value of 1372.8 or even close to it.
The postgres table has a few non-nullable columns and i have made sure all 170 records contain values. There is no record with missing value.
However, I am getting this strange error. I have also browse through stackoverflow but it seems like this has nothing to do with SAS but postgres. However, the value that i load into postgres is of same data type, always numeric and i have no clue why is this error prompting.
Log file:
NOTE: Appending WORK.WVVOL13 to NETCAP.MasterAssetRenewable.
NOTE: FORCE is specified, so dropping/truncating will occur.
NOTE: There were 18 observations read from the data set WORK.WVVOL13.
NOTE: 17 observations added.
NOTE: The data set NETCAP.MasterAssetRenewable has . observations and 18 variables.
ERROR: CLI execute error: ERROR: invalid input syntax for integer: "1372.8";
Code from SCD Type 1 Loader:
/*==========================================================================*
* Step: SCD Type 1 A5KQQF32.C20002Y5 *
* Transform: SCD Type 1 *
* Description: *
* *
* Source Table: User Written - A5KQQF32.C90001ZV *
* work.ncp_asset_re_toloadnew *
* Target Tables: MasterAssetRenewable - A5KQQF32.BE0000X2 *
* netcap.MasterAssetRenewable *
* Cross reference - A5KQQF32.C90001ZW *
* work.MasterAssetRenewable_xref *
* Changed records - work.WVVOJQO A5KQQF32.C90001ZX *
* New records - work.WVVOL13 A5KQQF32.C90001ZY *
*==========================================================================*/
options VALIDVARNAME = ANY VALIDMEMNAME = EXTEND;
%let transformID = %quote(A5KQQF32.C20002Y5);
%let trans_rc = 0;
%let etls_stepStartTime = %sysfunc(datetime(), datetime20.);
%let SYSLAST = %nrquote(work."ncp_asset_re_toloadnew"n);
%macro etls_scd_type_1;
/*---- Delete any pre-existing work tables ----*/
proc datasets lib = work nolist nowarn memtype = (data view);
delete etls_xref;
quit;
proc datasets lib = work nolist nowarn memtype = (data view);
delete "WVVOJQO"n;
quit;
proc datasets lib = work nolist nowarn memtype = (data view);
delete "WVVOL13"n;
quit;
/* Determine if the table exists */
%let etls_tableExist = %eval(%sysfunc(exist(netcap."MasterAssetRenewable"n, DATA)) or
%sysfunc(exist(netcap."MasterAssetRenewable"n, VIEW)));
/*---- Create a new table ----*/
%if (&etls_tableExist eq 0) %then
%do; /* if table does not exist */
%put %str(NOTE: Creating table ...);
data netcap."MasterAssetRenewable"n
(dbnull = (
"Id"n = NO
"DetailType"n = NO
"DependableFactor"n = NO
"StatusType"n = NO
"DeclaredGenerationMd"n = NO
"ActualGenerationMd"n = NO
"BusinessAreaId"n = YES
"PmuId"n = YES
"PpuId"n = YES
"CreatedFromId"n = YES
"CustomerName"n = YES
"CustomerNumber"n = YES
"SsuId"n = YES
"FeederNo"n = YES
"Lat"n = YES
"Lng"n = YES
"ReCapacity"n = NO
"TargetCommDate"n = NO));
attrib "Id"n length = 8
format = 20.
informat = 20.
label = 'Id';
attrib "DetailType"n length = 8
format = 11.
informat = 11.
label = 'DetailType';
attrib "DependableFactor"n length = 8
label = 'DependableFactor';
attrib "StatusType"n length = 8
format = 11.
informat = 11.
label = 'StatusType';
attrib "DeclaredGenerationMd"n length = 8
label = 'DeclaredGenerationMd';
attrib "ActualGenerationMd"n length = 8
label = 'ActualGenerationMd';
attrib "BusinessAreaId"n length = 8
format = 20.
informat = 20.
label = 'BusinessAreaId';
attrib "PmuId"n length = 8
format = 20.
informat = 20.
label = 'PmuId';
attrib "PpuId"n length = 8
format = 20.
informat = 20.
label = 'PpuId';
attrib "CreatedFromId"n length = 8
format = 20.
informat = 20.
label = 'CreatedFromId';
attrib "CustomerName"n length = $1024
format = $1024.
informat = $1024.
label = 'CustomerName';
attrib "CustomerNumber"n length = $1024
format = $1024.
informat = $1024.
label = 'CustomerNumber';
attrib "SsuId"n length = 8
format = 20.
informat = 20.
label = 'SsuId';
attrib "FeederNo"n length = $1024
format = $1024.
informat = $1024.
label = 'FeederNo';
attrib "Lat"n length = 8
label = 'Lat';
attrib "Lng"n length = 8
label = 'Lng';
attrib "ReCapacity"n length = 8
format = 11.
informat = 11.
label = 'ReCapacity';
attrib "TargetCommDate"n length = 8
format = DATETIME25.6
informat = DATETIME25.6
label = 'TargetCommDate';
call missing(of _all_);
stop;
run;
%rcSet(&syserr);
/*---- Create the indexes for a table ----*/
%put %str(NOTE: Creating indexes ...);
%macro etls_createIndexes;
proc sql;
connect to POSTGRES
(
DATABASE=netcap SERVER="unadevsaswas01.hq.tnb.com.my" AUTHDOMAIN="NetcapAuth"
);
reset noprint;
execute
(
create index "IX_MasterAssetRenewable_PpuId"
on "MasterAssetRenewable"
("PpuId")
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
create index "IX_MasterAssetRenewable_PmuId"
on "MasterAssetRenewable"
("PmuId")
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
create index "IX_MasterAssetRenewable_CreatedFromId"
on "MasterAssetRenewable"
("CreatedFromId")
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
create index "IX_MasterAssetRenewable_BusinessAreaId"
on "MasterAssetRenewable"
("BusinessAreaId")
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
create index "IX_MasterAssetRenewable_SsuId"
on "MasterAssetRenewable"
("SsuId")
) by POSTGRES;
%rcSet(&sqlrc);
disconnect from POSTGRES;
quit;
%rcSet(&sqlrc);
%mend etls_createIndexes;
%etls_createIndexes;
/*---- Create the integrity constraints for a table ----*/
%put %str(NOTE: Creating integrity constraints ...);
proc sql;
connect to POSTGRES
(
DATABASE=netcap SERVER="unadevsaswas01.hq.tnb.com.my" AUTHDOMAIN="NetcapAuth"
);
reset noprint;
execute
(
alter table "MasterAssetRenewable"
add primary key ("Id")
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
alter table "MasterAssetRenewable"
add foreign key ("PmuId") references "MasterAssetPmu"
) by POSTGRES;
%rcSet(&sqlrc);
execute
(
alter table "MasterAssetRenewable"
add foreign key ("PpuId") references "MasterAssetPpu"
) by POSTGRES;
%rcSet(&sqlrc);
disconnect from POSTGRES;
quit;
%rcSet(&sqlrc);
%end; /* if table does not exist */
/* Determine if the table exists */
%let etls_tableExist = %eval(%sysfunc(exist(work."MasterAssetRenewable_xref"n, DATA)) or
%sysfunc(exist(work."MasterAssetRenewable_xref"n, VIEW)));
/*---- Create a new table ----*/
%if (&etls_tableExist eq 0) %then
%do; /* if table does not exist */
%put %str(NOTE: Creating table ...);
data work."MasterAssetRenewable_xref"n;
attrib "Id"n length = 8
format = 20.
informat = 20.
label = 'Id';
attrib "compare_digest"n length = $32
format = $32.
informat = $32.;
call missing(of _all_);
stop;
run;
%rcSet(&syserr);
/*---- Create the integrity constraints for a table ----*/
%put %str(NOTE: Creating integrity constraints ...);
proc datasets library=work nolist;
modify "MasterAssetRenewable_xref"n;
ic create not null ("Id"n);
quit;
%rcSet(&syserr);
%end; /* if table does not exist */
proc datasets lib = work nolist nowarn memtype = (data view);
delete W159RVJL;
quit;
proc sql;
create view work.W159RVJL as
select
"Id"n
format = 20.
informat = 20.,
"DetailType"n,
"DependableFactor"n,
"StatusType"n,
"DeclaredGenerationMd"n,
"ActualGenerationMd"n,
"BusinessAreaId"n,
"PmuId"n
format = 20.
informat = 20.,
"PpuId"n
format = 20.
informat = 20.,
"CreatedFromId"n,
"CustomerName"n length = 1024
format = $1024.
informat = $1024.,
"CustomerNumber"n length = 1024
format = $1024.
informat = $1024.,
"SsuId"n,
"FeederNo"n length = 1024
format = $1024.
informat = $1024.,
"Lat"n,
"Lng"n,
"ReCapacity"n
format = 11.
informat = 11.,
"TargetCommDate"n
format = DATETIME25.6
informat = DATETIME25.6
from work."ncp_asset_re_toloadnew"n
;
quit;
%let SYSLAST = work.W159RVJL;
/* create work xref table */
data work.etls_xref(keep = Id compare_digest);
length compare_digest $ 32;
set netcap."MasterAssetRenewable"n( keep = Id ReCapacity FeederNo DeclaredGenerationMd);
/* create digest - version 2.1 */
compare_digest = put(md5(catq(' ', ReCapacity, FeederNo, DeclaredGenerationMd)), $hex32.);
run;
%rcSet(&syscc);
/*---- SCD Type 1 processing: hash lookup method ----*/
data
/* Changed Records Table */
work."WVVOJQO"n( keep = Id ReCapacity FeederNo DeclaredGenerationMd compare_digest)
/* New Records Table */
work."WVVOL13"n;
drop source_digest;
length source_digest $ 32;
if 0 then
set work.etls_xref;
if _N_ eq 1 then
do;
declare hash hct(dataset: 'work.etls_xref', hashexp: 10);
hct.defineKey("Id");
hct.defineData("Id", "compare_digest");
hct.defineDone();
end;
set work.W159RVJL;
/* create digest - version 2.1 */
source_digest = put(md5(catq(' ', ReCapacity, FeederNo, DeclaredGenerationMd)), $hex32.);
/* match */
if hct.find() eq 0 then
do;
/* scd type 1 records */
if source_digest ne compare_digest then
do;
compare_digest = source_digest;
output work."WVVOJQO"n;
end;
end;
/* new records */
else if hct.find() ne 0 then
do;
compare_digest = source_digest;
output work."WVVOL13"n;
end;
run;
%rcSet(&syscc);
/* changed records table - record check */
%let etls_recCheckExist = 0;
%let etls_change_rows = 0;
%macro etls_recordCheck;
%let etls_recCheckExist = %eval(%sysfunc(exist(work."WVVOJQO"n, DATA)) or
%sysfunc(exist(work."WVVOJQO"n, VIEW)));
%if (&etls_recCheckExist) %then
%do;
%local etls_syntaxcheck;
%let etls_syntaxcheck = %sysfunc(getoption(syntaxcheck));
/* Turn off syntaxcheck option to perform following steps */
options nosyntaxcheck;
data _null_;
set work."WVVOJQO"n( obs=1 );
call symput("etls_change_rows",'1');
run;
/* Reset syntaxcheck option to previous setting */
options &etls_syntaxcheck;
%end;
%mend etls_recordCheck;
%etls_recordCheck;
%rcSet(&syscc);
/* new records table - record check */
%let etls_recCheckExist = 0;
%let etls_new_rows = 0;
%macro etls_recordCheck;
%let etls_recCheckExist = %eval(%sysfunc(exist(work."WVVOL13"n, DATA)) or
%sysfunc(exist(work."WVVOL13"n, VIEW)));
%if (&etls_recCheckExist) %then
%do;
%local etls_syntaxcheck;
%let etls_syntaxcheck = %sysfunc(getoption(syntaxcheck));
/* Turn off syntaxcheck option to perform following steps */
options nosyntaxcheck;
data _null_;
set work."WVVOL13"n( obs=1 );
call symput("etls_new_rows",'1');
run;
/* Reset syntaxcheck option to previous setting */
options &etls_syntaxcheck;
%end;
%mend etls_recordCheck;
%etls_recordCheck;
%rcSet(&syscc);
/*---- target table: update/append rows ----*/
/* target table: update change rows */
%if &etls_change_rows ge 1 %then
%do;
proc sql;
update netcap."MasterAssetRenewable"n as m
set "ReCapacity"n = (select "ReCapacity"n from work."WVVOJQO"n as t
where m."Id"n = t."Id"n),
"FeederNo"n = (select "FeederNo"n from work."WVVOJQO"n as t
where m."Id"n = t."Id"n),
"DeclaredGenerationMd"n = (select "DeclaredGenerationMd"n from work."WVVOJQO"n as t
where m."Id"n = t."Id"n)
where exists (select * from work."WVVOJQO"n as t
where m."Id"n = t."Id"n);
quit;
%rcSet(&syscc);
%end;
/* target table - append new rows */
%if &etls_new_rows ge 1 %then
%do;
proc append base = netcap."MasterAssetRenewable"n
data = work."WVVOL13"n force nowarn;
run;
%rcSet(&syscc);
%end;
/*---- cross reference table: update/append rows ----*/
/* cross reference table: update change rows */
%if &etls_change_rows ge 1 %then
%do;
proc sql;
update work."MasterAssetRenewable_xref"n as m
set compare_digest = (select compare_digest from work."WVVOJQO"n as t
where m."Id"n = t."Id"n)
where exists (select * from work."WVVOJQO"n as t
where m."Id"n = t."Id"n);
quit;
%rcSet(&syscc);
%end;
/* cross reference table - append new rows */
%if &etls_new_rows ge 1 %then
%do;
proc append base = work."MasterAssetRenewable_xref"n
data = work."WVVOL13"n( keep = Id compare_digest)
force nowarn;
run;
%rcSet(&syscc);
%end;
/* Delete work.etls_xref table */
proc datasets lib = work nolist nowarn memtype = (data view);
delete etls_xref;
quit;
%mend etls_scd_type_1;
/* execute etls_scd_type_1 */
%etls_scd_type_1
/** Step end SCD Type 1 **/
i've created a series of plots using proc gbarline and I wish to export all plots to one pdf instead of just the first plot, I am having two issues:
the plot does not export to pdf unless I print the first plot twice, hence why I use the statement
%if &index. = 1 %then %do;
<statements>;
%end;
the pdf only contains the first plot
The code I use is below:
%macro test_pdf;
data snp (drop=i);
do i = 1 to 100;
y = ranuni(0);
x1 = ranuni(0) * 5;
x2 = ranuni(0) * 10;
x3 = ranuni(0) * 7;
x4 = ranuni(0) * 4;
x5 = ranuni(0) * 100;
x6 = ranuni(0) * 50;
x7 = ranuni(0) * 1000;
x8 = ranuni(0) * 10000;
x9 = ranuni(0) * 9999;
x10 = ranuni(0) * 5984;
x11 = ranuni(10) * 5;
x12 = ranuni(10) * 10;
x13 = ranuni(10) * 7;
x14 = ranuni(10) * 4;
x15 = ranuni(10) * 100;
x16 = ranuni(10) * 50;
x17 = ranuni(10) * 1000;
x18 = ranuni(10) * 10000;
x19 = ranuni(10) * 9999;
x20 = ranuni(10) * 5984;
x21 = ranuni(20) * 5;
x22 = ranuni(20) * 10;
x23 = ranuni(20) * 7;
x24 = ranuni(20) * 4;
x25 = ranuni(20) * 100;
x26 = ranuni(20) * 50;
x27 = ranuni(20) * 1000;
x28 = ranuni(20) * 10000;
x29 = ranuni(20) * 9999;
x30 = ranuni(20) * 5984;
x31 = ranuni(30) * 5;
x32 = ranuni(30) * 10;
x33 = ranuni(30) * 7;
x34 = ranuni(30) * 4;
x35 = ranuni(30) * 100;
x36 = ranuni(30) * 50;
x37 = ranuni(30) * 1000;
x38 = ranuni(30) * 10000;
x39 = ranuni(30) * 9999;
x40 = ranuni(30) * 5984;
output;
end;
run;
PROC CONTENTS DATA = snp OUT = snp_contents NOPRINT;
RUN;
PROC SQL NOPRINT;
SELECT name INTO: snp_factors
separated by " "
FROM snp_contents
WHERE varnum > 1;
SELECT name INTO: snp_response
FROM snp_contents
WHERE varnum = 1;
SELECT max(length(name)) INTO: max_length
FROM snp_contents;
QUIT;
ODS HTML CLOSE;
ODS HTML;
QUIT;
%LET timestamp = %sysfunc(putn(%sysfunc(date()),yymmddn8.));
%LET hourstamp = %sysfunc(compress(%sysfunc(TIME(),time.),%str( :)));
ODS TRACE ON;
ODS PDF FILE = "&ROOT\output_data\_×tamp._&hourstamp._Histogram_gbarline.pdf";
ODS SELECT gbarlin;
%LET index = 1;
%DO %UNTIL (%SCAN(&snp_factors.,&index.," ")=);
%LET factors = %SCAN(&snp_factors.,&index.," ");
%IF &index. = 1 %THEN
%DO;
PROC GBARLINE DATA=snp
;
BAR &factors.
/
FRAME LEVELS=10
TYPE=PCT
MISSING
COUTLINE=BLACK
;
PLOT / SUMVAR=&snp_response.
TYPE=MEAN
;
RUN;
QUIT;
%END;
PROC GBARLINE DATA=snp
;
BAR &factors.
/
FRAME LEVELS=10
TYPE=PCT
MISSING
COUTLINE=BLACK
;
PLOT / SUMVAR=&snp_response.
TYPE=MEAN
;
RUN;
QUIT;
ODS PDF CLOSE;
%LET index = %EVAL(&Index + 1);
%END;
%mend;
%test_pdf;
You are closing the PDF inside the %DO %UNTIL loop.
Change
…
ODS PDF CLOSE;
%LET index = %EVAL(&Index + 1);
%END;
to
…
%LET index = %EVAL(&Index + 1);
%END;
ODS PDF CLOSE;
Because you closed inside the loop, only the first iteration was in the PDF output. The subsequent ODS PDF CLOSE statements inside the loop were accepted by SAS and discarded silently (no log messages) because the PDF destination was already closed.
This question is a follow-up to my previous question: SAS - pdf output with changed bookmarks
I have added the ODS PROCLABLE and DESCRIPTION to the code and the bookmarks are created fine. But if I click on any of the bookmarks, nothing happens - the pdf file does not jump to the specific graph. Why is to so ? Does anything need to be added to the code ?
data out_i_a; set sashelp.retail; run;
data out_ii_b; set sashelp.retail; run;
data y;
length saz tef x1 x2 $100;
input saz $ tef $ x1 $ x2;
datalines;
i a desc1 desc1a
ii b desc2 desc2a
;
run;
%macro grafy();
proc sql;
select count(*) into: pocet from y;
quit;
ods _all_ close;
goptions hsize=20cm vsize=8cm;
ods pdf file="\\srv05\nt05g\TEST\GRAF\TOT_testing.pdf";
ods layout gridded columns=1;
%do i=1 %to &pocet;
data _null_;
set y (obs=&i);
call symput("saz" ,strip(saz));
call symput("tef" ,strip(tef));
call symput("x1" ,strip(x1));
call symput("x2" ,strip(x2));
run;
ods region;
ods pdf text="&saz._&tef";
symbol1 interpol=join height=10pt VALUE=NONE LINE=1 WIDTH=1 CV= _STYLE_;
symbol2 interpol=join height=10pt VALUE=NONE LINE=1 WIDTH=1 CV= _STYLE_;
Legend1 value=('SALES' 'YEAR');
axis1 label=('# sales');
axis3 label=('# year');
axis2 label=('date');
ODS PROCLABEL "&x1 &x2 SALES"; /* BOOKMARK1 */
proc gplot data= out_&saz._&tef;
plot (SALES)*DATE / overlay skipmiss
VAXIS=AXIS1
HAXIS=AXIS2 LEGEND=Legend1;
plot2 (YEAR)*DATE / overlay skipmiss
VAXIS=AXIS3
HAXIS=AXIS2 LEGEND=Legend1
DESCRIPTION="by Date";
run;
ods region;
symbol1 interpol=join height=10pt VALUE=NONE LINE=1 WIDTH=1 CV= _STYLE_;
symbol2 interpol=join height=10pt VALUE=NONE LINE=1 WIDTH=2 CV= _STYLE_;
Legend1 value=('year' 'month');
axis1 label=('in %, p.a.');
axis2 label=('date');
ODS PROCLABEL "&x1 &x2 SALES2"; /* BOOKMARK2 */
proc gplot data= out_&saz._&tef;
plot (YEAR MONTH)*DATE / overlay skipmiss
DESCRIPTION="YEAR MONTH"
VAXIS=AXIS1
HAXIS=AXIS2 LEGEND=Legend1;
run;
%end;
ods layout end;
ods pdf close;
%mend;
%grafy();
Thank you for any suggestions.
I wonder if there is an issue with ODS LAYOUT here. It looks like the TOC bookmarks can only link to new pages: so if you add
ods pdf startpage=now;
at some point (say at the end of your %do loop), you'll be able to jump to that point. But if the layout just spans several pages, it doesn't look like you can link to it inside the page - at least as far as I can figure.