SAS - pdf output with bookmarks not reacting - pdf

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.

Related

SAS solve optimization problem for each row of a dataset

I have a dataset like the following:
data have;
id=1; x1=10; x2=3; x3=5; y=220;
y1g=12; y2g=6; y3g=10;
output;
id=2; x1=7; x2=0; x3=3; y=100;
y1g=12; y2g=0; y3g=10;
output;
run;
for each record I want to had values for y1, y2, y3, such that
x1*y1+x2*y2+x3*y3=y
0=<y1<=12
0=<y2<=6
0=<y3<=10
I am not sure of which can be the objective function, but to fix the ideas
I might want that the solutions are as similar as possible to some initial guess, y1g ,y2g, y3g.
so for instance the objective might be:
min (y1-y1g)**2+(y2-y2g)**2+(y3-y3g)**2
I am using SAS9 M5 and have to apply the program to a dataset of about 100000 records.
can you suggest me with the proc optmodel code?
thank you very much in advance
Although your solution is infeasible with your constraints, this is what the optmodel code looks like:
proc optmodel;
set row;
num id;
num x1{row};
num x2{row};
num x3{row};
num y1g{row};
num y2g{row};
num y3g{row};
num y{row};
num y1sol{row};
num y2sol{row};
num y3sol{row};
var y1;
var y2;
var y3;
read data have into row=[id]
x1 x2 x3 y y1g y2g y3g
;
con con1: x1[id]*y1 + x2[id]*y2 + x3[id]*y3 = y[id];
con con2: 0 <= y1 <= 12;
con con3: 0 <= y2 <= 6;
con con4: 0 <= y3 <= 10;
min sum_squared_dif = ( (y1-y1g[id])**2+(y2-y2g[id])**2+(y3-y3g[id])**2 );
cofor {i in row} do;
id = i;
solve;
/* Save each individual solution */
y1sol[id] = y1.sol;
y2sol[id] = y2.sol;
y3sol[id] = y3.sol;
end;
print y1sol y1g y2sol y2g y3sol y3g;
quit;
Note that the first row has an infeasible solution.

SAS: ODS Pdf width of sgplot charts

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

Error when loading data into Postgres table from SAS(Invalid input syntax for integer)

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 **/

create a pdf of all bar-line plots appended together

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\_&timestamp._&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.

How do I transpose only single column keeping one column the same?

How do I transpose like this?
I know to Transpose it altogether but this one i am not familiar with.
This should do the job:
data a;
cust = "A";
channels = 20;
output;
cust = "A";
channels = 30;
output;
cust = "A";
channels = 40;
output;
cust = "B";
channels = 200;
output;
cust = "B";
channels = 300;
output;
cust = "B";
channels = 0;
output;
run;
proc transpose data=a out=b;
by cust;
var channels;
run;