03-13-2025
_Manhattan
Quartz | Level 8
Member since
03-07-2022
- 64 Posts
- 28 Likes Given
- 1 Solutions
- 3 Likes Received
-
Latest posts by _Manhattan
Subject Views Posted 1591 07-25-2024 04:24 AM 1593 07-25-2024 04:23 AM 1676 07-24-2024 03:46 AM 1758 07-23-2024 03:23 AM 1865 07-22-2024 09:32 AM 661 07-22-2024 05:24 AM 2921 07-19-2024 09:40 AM 2939 07-19-2024 09:27 AM 2994 07-19-2024 09:20 AM 3016 07-19-2024 08:48 AM -
Activity Feed for _Manhattan
- Posted Re: How to superscript in ods pdf? on SAS Programming. 07-25-2024 04:24 AM
- Posted Re: How to superscript in ods pdf? on SAS Programming. 07-25-2024 04:23 AM
- Posted Re: How to superscript in ods pdf? on SAS Programming. 07-24-2024 03:46 AM
- Posted Re: How to superscript in ods pdf? on SAS Programming. 07-23-2024 03:23 AM
- Posted How to superscript in ods pdf? on SAS Programming. 07-22-2024 09:32 AM
- Posted Re: Conditional footnotes in ods pdf on ODS and Base Reporting. 07-22-2024 05:24 AM
- Posted Re: Conditional footnotes in ods pdf on ODS and Base Reporting. 07-19-2024 09:40 AM
- Posted Re: Conditional footnotes in ods pdf on ODS and Base Reporting. 07-19-2024 09:27 AM
- Posted Re: Conditional footnotes in ods pdf on ODS and Base Reporting. 07-19-2024 09:20 AM
- Posted Re: Conditional footnotes in ods pdf on ODS and Base Reporting. 07-19-2024 08:48 AM
- Posted Conditional footnotes in ods pdf on ODS and Base Reporting. 07-19-2024 07:20 AM
- Posted Re: Customize proc report font, borderwidth, space between two tables on SAS Programming. 07-09-2024 08:26 AM
- Liked Re: Customize proc report font, borderwidth, space between two tables for Cynthia_sas. 07-09-2024 08:25 AM
- Posted Re: Customize proc report font, borderwidth, space between two tables on SAS Programming. 06-21-2024 08:41 AM
- Liked Re: Customize proc report font, borderwidth, space between two tables for ballardw. 06-21-2024 08:40 AM
- Posted Customize proc report font, borderwidth, space between two tables on SAS Programming. 06-20-2024 06:10 AM
- Posted How to adapt page margins for odd and even pages on ODS and Base Reporting. 05-29-2024 06:27 AM
- Posted Re: Controlling page breaks when using proc report on ODS and Base Reporting. 05-15-2024 04:17 AM
- Posted Re: Controlling page breaks when using proc report on ODS and Base Reporting. 05-14-2024 07:26 AM
- Posted Re: Controlling page breaks when using proc report on ODS and Base Reporting. 05-14-2024 07:11 AM
-
Posts I Liked
Subject Likes Author Latest Post 3 1 2 3 1 -
My Liked Posts
Subject Likes Posted 1 08-10-2023 03:36 AM 1 05-23-2023 10:57 AM 1 08-04-2022 10:01 AM
07-25-2024
04:24 AM
This blog post has been helpful https://blogs.sas.com/content/sgf/2020/03/20/how-to-debug-5-common-sas-software-font-issues/
... View more
07-25-2024
04:23 AM
I just realised that I did not use the right file path. With the following code I got the Log down below
proc fontreg
mode=all
msglevel=verbose
;
fontfile "C:\Windows\Fonts\calibri.ttf";
run;
WARNING: The "Calibri" font family being processed supports more character encodings than the
existing family of the same name in the SAS registry. Only the encodings currently
supported by the family in the SAS registry will be available.
NOTE: The font "Calibri" (Style: Regular, Weight: Normal) has been replaced in the SAS Registry
at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Calibri]. Because it is a TRUETYPE font, it can be
referenced as "Calibri" or "<ttf> Calibri" in SAS. The font resides in file
"C:\Windows\Fonts\calibri.ttf".
I read that as "it worked". Unfortunately, my output still looks the same
... View more
07-24-2024
03:46 AM
I have run the following code
proc registry listhelp startat='ods\fonts'; run;
and noticed that I do not have calibri as a font installed in SAS.
However, if I try to add Fonts with the following code
proc fontreg
mode=add
msglevel=normal
usesashelp
;
truetype "C:\yourpath\Microsoft\Windows\Fonts";
run;
I receive the ERROR: User does not have appropriate authorization level for file SASHELP.REGSTRY.ITEMSTOR
Do you know any work around to resolve this issue? Alternatively, I will consider using Albany MT (thanks @Cynthia_sas for the short overview of the comparison of the fonts)
... View more
07-23-2024
03:23 AM
Hi @Cynthia_sas,
I have used your code to troubleshoot. The problem seems to be the definition of a fontfamily. If I use the following code the problem occurs. But without the fontfamily statement it works as intended. Unfortunately, I need a font different to the default one. Arial would be fine as well, but the problem occurs there too.
data testsuper;
length tline $200;
infile datalines dlm =",";
input ord tline $;
datalines;
1, Here^{super 1} There^{super 2} and what about here^{super 3}
2, Twas^{super 4} and what about now^{super 5}
3, No other context given but this^{super 6}
;
run;
ods escapechar="^";
options papersize=a4 orientation=portrait nobyline nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods pdf file="yourpath\testSUPER.pdf";
proc report data=testsuper;
column ord tline;
define ord / order;
define tline / "TestLine" display style(column)=[cellwidth=15cm fontfamily=calibri fontsize=10pt];
run;
ods pdf close;
... View more
07-22-2024
09:32 AM
Hello,
I would like to add some superscript to my PDF document. I have found some information on how to do this, but my output looks a bit off.
I have imported an excel file (see screenshot below) to test how the outcome looks. I would like the outcome to look like in the first row "HERE". You can see that the superscript "1" is directly matched to the text. I have noticed the longer the string is the wider the gap between the content and the text gets. Do you have an idea how to stick the superscript to the text like in the first row?
proc import
datafile="yourpath\superscript_test.xlsx"
out=supers
dbms=excel
replace;
run;
options papersize=a4 orientation=portrait nobyline nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods pdf file="yourpath\testSUPER.pdf";
proc report data=supers;
column test;
define test / "test" display style(column)=[cellwidth=15cm fontfamily=calibri fontsize=10pt];
run;
ods pdf close;
Output PDF::
Excel:
... View more
07-22-2024
05:24 AM
Hi @Cynthia_sas ,
thank your for your input. Your idea works fine in the code I have posted here, but again not in my "original" one. I have tried to recreate an example to visualize my problem. Even though it is rubbish data the problem should be understandable. Short description of the problems:
1) The Footnote is printed below the according proc report step - not at the end of the page.
2) There is a footnote printed at page 2 that states "footnote: #byval1" which seems to be similar to the html output issue
The screenshot below the code shows the problem aswell.
proc datasets lib=work nolist; delete sample_data input_data mean: VariableInfo freq: ;run ;quit;
%let yourpath=\FootnoteTest.pdf;
ods listing;
/*** Example Data ***/
data work.sample_data;
input EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B;
datalines;
10 20 30 40 50 1 2 3 2 3
15 25 35 45 55 1 3 4 3 2
5 10 15 20 25 2 2 3 3 2
20 30 40 50 60 4 3 2 1 1
25 35 45 55 65 1 1 1 2 3
;
run;
data work.input_data;
length FT $20 Info1 $1000 Info2 $1000;
input FT $ Info1 $ Info2 $ Sort;
infile datalines delimiter=",";
datalines;
FootnoteONE, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
FootnoteTWO, AGHK50A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
FootnoteTHREE, AGHK50B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
FootnoteFOUR, AGHK50C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
FootnoteFIVE, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
FootnoteSIX, BGKO28A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
FootnoteSEVEN, BGKO28B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
FootnoteEIGHT, Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
FootnoteNINE, EZGH25A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
FootnoteTEN, EZGH25B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
FootnoteELEVEN, EZGH25C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
FootnoteTWELVE, EZGH25D,Item D Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
FootnoteTHIRTEEN, EZGH25E,Item E Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
;
/* Using proc sql for a Sorting Variable which is used to iterate trough the do-loop */
proc sql noprint;
select distinct Sort into :Sort separated by " "
from work.input_data;
quit;
%put &Sort;
%let varlistE = EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E;
%let varlistA = AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B;
/* Mean Calculation */
proc means data=work.sample_data noprint;
var &varlistE;
output out=work.mean_ezgh;
run;
%macro meandata;
%do i = 1 %to %sysfunc(countw(&varlistE));
%let vmean = %scan(&varlistE, &i);
data work.mean&vmean;
set work.mean_ezgh (keep=&vmean);
run;
%end;
%mend meandata;
%meandata;
/* Freq calculation */
%macro freqdata;
%do i = 1 %to %sysfunc(countw(&varlistA));
%let vfreq = %scan(&varlista, &i);
proc freq data=work.sample_data;
tables &vfreq/ out=work.freq&vfreq;
run;
%end;
%mend freqdata;
%freqdata;
/*** Macro Loop ***/
%macro Testloop;
%do i = 1 %to %sysfunc(countw(&Sort.));
%let SortID = %scan(&sort, &i);
%let VariableA = %scan(&varlistA, &i);
%let VariableE = %scan(&varlistE, &i);
/* Compute Variable Information for each Variable */
data VariableInfo;
set work.input_data;
where Sort = &SortID.;
drop Sort;
run;
%local Info1Items;
%let Info1Items=;
PROC SQL noprint;
SELECT distinct Info1 INTO :Info1Items SEPARATED BY " "/*new*/
FROM work.input_data
WHERE Sort = &SortID.
AND Info1 not in ('' 'Variable');
QUIT;
ods pdf startpage=no;
ods layout gridded columns=1;
ods region;
/* Report Variable Information for each Variable */
footnote "Footnote: #byval1";
proc report data=VariableInfo noheader;
by FT;
column Info1 Info2;
run;
ods layout end;
%MACRO PrinItemStats(Item=,colPosition=);
ods layout gridded columns=1;
ods region;
%if %sysfunc(exist(freq&Item.)) %then %do;
/* Print Frequency Table */
proc report data=freq&Item.;
column &Item. COUNT PERCENT;
define &Item / display "&Item.";
define COUNT / display "Absolut";
define PERCENT / display "Percent";
run;
%end;
%if %sysfunc(exist(mean&Item.)) %then %do;
/* Print Mean Table */
proc report data=mean&Item.;
column &Item.;
run;
%end;
ods layout end;
%MEND PrinItemStats;
%local j currItem;
%LET j=1;
%LET currItem=%SCAN(&Info1Items.,&j.,%STR( ));
%DO %WHILE(%LENGTH(&currItem.)>0);
%PrinItemStats(Item=&currItem.);
%LET j=%EVAL(&j.+1);
%LET currItem=%SCAN(&Info1Items.,&j.,%STR( ));
%END;
%end;
%mend Testloop;
ods _all_ close;
options papersize=a4 orientation=portrait leftmargin=1.5cm rightmargin=1.5cm topmargin=1.5cm bottommargin=1.5cm nodate nonumber nobyline nobysorted;
ods pdf file="&yourpath.";
%Testloop;
ods pdf close;
... View more
07-19-2024
09:40 AM
I see what you are saying. But sadly it is not working for my initial problem as I need the footnotes. Thank you anyway!
... View more
07-19-2024
09:27 AM
Alright, thanks I appreciate it! May I ask if you could modify the code to show how to simplify it? Maybe I could integrate your approach to update my original code.
... View more
07-19-2024
09:20 AM
Hey Paige, thank your for your reply. Could you elaborate on that thought? In what way would you use a title statement to generate the footnotes? I am not eager to use the footnote statement. It just seemed like the obvious thing to do if one wants to create footnotes^^
... View more
07-19-2024
08:48 AM
Hey Chris,
thank you for you reply! Unfortunately, with your approach the footnotes are indeed updated, but not placed where they are supposed to be (at the bottom of the page):
Instead, the footnotes are printed below the proc report step which is not needed.
... View more
07-19-2024
07:20 AM
Hello,
I would like to know if there is any way to program conditional footnotes in ods pdf. I have tried to implement some kind of if/then logic in my code which contains a more or less complex macro. Beforehand, I have defined the footnote text in excel, imported the excel as a sas dataset and created a macro variable with proc sql. The idea was to iterate over my code with a do loop and always print a footnote if the footnote-text-macro-variable is not empty. Now, what is a bit problematic is that as I was recreating an example with the sashelp data sets my code worked just fine. But in my original code it was always just generating the first footnote on every page. With the use of some "put" statements I have figured out that the macro variable is returning the correct value, but the printing is somehow not working.
LONG STORY SHORT: I am looking for a way to generate footnotes at the end of the page (not at the end of each proc report step) that is different to the one I have used in the code below. I can not show you my original code, but let me assure you that I have tried a lot of stuff to get the footnotes working. I am guessing the macro structure in my original code is messing with the functioning of the approach below. If you have any idea how to generate some kind of conditional footnotes please let me know.
ods escapechar="^";
data cars_with_sort;
set sashelp.cars (obs=55);
select (Make);
when ("Acura") Sort = 1;
when ("Audi") Sort = 2;
when ("BMW") Sort = 3;
when ("Buick") Sort = 4;
otherwise Sort = .;
end;
run;
proc sql noprint;
select distinct Sort into :Sort separated by " "
from cars_with_sort;
quit;
%macro Foot;
%do i = 1 %to 4;
%let SortID = %scan(&Sort., &i.);
proc sql noprint;
select distinct Make into :FootnoteT separated by " "
from cars_with_sort
where Sort = &SortID.;
quit;
%put Fußnote = &FootnoteT;
%if %length(&FootnoteT) > 0 %then %do;
footnote j=l "^S={fontfamily=calibri font_size=10pt} &FootnoteT";
%end;
data cars;
set cars_with_sort;
where Sort = &SortID.;
run;
ods layout gridded;
proc report data=cars;
column Make Sort;
define Make / "Car Model";
define Sort / noprint;
run;
ods layout end;
%end;
%mend Foot;
options papersize=a4 orientation=portrait nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods listing close;
ods pdf file = "yourpath\FootnotesTest.pdf";
%Foot;
ods pdf close;
Kind regards
... View more
07-09-2024
08:26 AM
Sorry for my late response, I have overseen the notification. Thank you for your time and advice, I appreciate it! It worked exactly as intended.
Kind regards
... View more
06-21-2024
08:41 AM
Thank you, that worked for me! 🙂 I do not mark it as a solution yet, as I am still struggling with the space between the proc reprort tables. Do you have any idea how to resolve that issue?
... View more
06-20-2024
06:10 AM
Hey guys,
quick question. I would like to customize my proc report tables that I print with ODS PDF:
1. I would like to use calibri as a font.
2. I would like to define the borderwidth of the table (or use a different approach to change the font family - see below).
3. I would like to shrink the space between two proc report tables.
For the First problem I have used proc template. Unfortunately, the table borders change with the defined style. The borders WITHOUT the template style "calib" look like this:
WITH the template style "calib" they look like this:
So either I would like to customize the borders OR use a different approach to change the font family. I do not need the bold borders.
Furthermore, for the third Problem I would like to shrink the marked space between the tables:
It is okay if there is still some space, but it should just not be as big.
My example code looks like this. The style command "borderbottomwidth" and "bordertopwidth" do not change anything. But thats what I have tried so far:
proc template;
define style Styles.calib;
parent=styles.printer;
replace fonts /
'docFont' = ("Calibri",10pt);
end;
run;
ods pdf startpage=no;
options papersize=a4 printerpath=pdf orientation=portrait leftmargin=1.5cm rightmargin=1.5cm topmargin=1.5cm bottommargin=1.5cm nodate nonumber;
ods listing close;
ods pdf file="yourpath\.pdf";
proc report data=sashelp.cars(obs=10) noheader style(report)={borderbottomwidth=0.1cm};
columns make model type;
run;
proc report data=sashelp.baseball(obs=10) noheader style(report)={bordertopwidth=0.1cm};
columns Name Team;
run;
ods pdf close;
Does anyone know how to handle these issues?
Kind regards
... View more
05-29-2024
06:27 AM
Hello,
I want to adapt the page margins of my pdf report in dependency of the odd/even pagenumbers. Till now, I have tried to work with the "leftmargin" etc. options in ods pdf and the ods layout gridded statements. One of the problems I have encountered is that the page numbers are affected by the margin options as well which is not something I want. It would be fine though, if the page numbers are printed at the bottom left/right part of the page according to the odd/even page numbers. Could you help me to achieve the desired result? My code looks like this:
proc datasets lib=work nolist; delete sample_data input_data mean: VariableInfo freq: ;run ;quit;
%let yourpath=c:\;
ods listing;
/*** Example Data ***/
data work.sample_data;
input EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B CGHK50A CGHK50B CGHK50C DGHK50A DGHK50B DGHK50C;
datalines;
10 20 30 40 50 1 2 3 2 3 1 2 3 2 3 1
15 25 35 45 55 1 3 4 3 2 1 3 4 3 2 1
5 10 15 20 25 2 2 3 3 2 2 2 3 3 2 1
20 30 40 50 60 4 3 2 1 1 4 3 2 1 1 1
25 35 45 55 65 1 1 1 2 3 1 1 1 2 3 1
5 10 15 20 25 2 2 3 3 2 2 2 3 3 2 1
20 30 40 50 60 4 3 2 1 1 4 3 2 1 1 1
25 35 45 55 65 1 1 1 2 3 1 1 1 2 3 1
;
run;
data work.input_data;
length Info1 $1000 Info2 $1000;
input Info1 $ Info2 $ Sort;
infile datalines delimiter=",";
datalines;
Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test,1
AGHK50A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test,1
AGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,1
AGHK50C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test SpaceTest,1
Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
BGKO28A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
BGKO28B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,2
Variable,Answer your Item Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
EZGH25A,Item A Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
EZGH25B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
EZGH25C,Item C Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
EZGH25D,Item D Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
EZGH25E,Item E Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,3
CGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,4
CGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,4
CGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,4
DGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,5
DGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,5
DGHK50B,Item B Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space Test Space,5
;
/* Using proc sql for a Sorting Variable which is used to iterate trough the do-loop */
proc sql noprint;
select distinct Sort into :Sort separated by " "
from work.input_data;
quit;
%put &Sort;
%let varlistA = AGHK50A AGHK50B AGHK50C BGKO28A BGKO28B EZGH25A EZGH25B EZGH25C EZGH25D EZGH25E CGHK50A CGHK50B CGHK50C DGHK50A DGHK50B DGHK50C;
/* Freq calculation */
%macro freqdata;
%do i = 1 %to %sysfunc(countw(&varlistA));
%let vfreq = %scan(&varlista, &i);
proc freq data=work.sample_data;
tables &vfreq/ out=work.freq&vfreq;
run;
%end;
%mend freqdata;
%freqdata;
/*** Macro Loop ***/
%macro Testloop;
%do i = 1 %to %sysfunc(countw(&Sort.));
%let SortID = %scan(&sort, &i);
%let VariableA = %scan(&varlistA, &i);
/* Compute Variable Information for each Variable */
data VariableInfo;
set work.input_data;
where Sort = &SortID.;
drop Sort;
run;
%local Info1Items;
%let Info1Items=;
PROC SQL noprint;
SELECT distinct Info1 INTO :Info1Items SEPARATED BY " "
FROM work.input_data
WHERE Sort = &SortID.
AND Info1 not in ('' 'Variable');
QUIT;
ods layout gridded x=1cm columns=1;
ods region;
/* Report Variable Information for each Variable */
proc report data=VariableInfo noheader;
column Info1 Info2;
run;
ods layout end;
ods layout gridded x=1cm columns=2;
%MACRO PrinItemStats(Item=,colPosition=);
ods region;
%if %sysfunc(exist(freq&Item.)) %then %do;
/* Print Frequency Table */
proc report data=freq&Item.;
column &Item. COUNT PERCENT;
define &Item / display "&Item.";
define COUNT / display "Absolut";
define PERCENT / display "Percent";
run;
%end;
%MEND PrinItemStats;
%local j currItem;
%LET j=1;
%LET currItem=%SCAN(&Info1Items.,&j.,%STR( ));
%DO %WHILE(%LENGTH(&currItem.)>0);
%PrinItemStats(Item=&currItem.);
%LET j=%EVAL(&j.+1);
%LET currItem=%SCAN(&Info1Items.,&j.,%STR( ));
%END;
ods layout end;
%end;
%mend Testloop;
/* Style template for page numbers to be put at the bottom of the page */
proc template;
define style move;
parent=styles.pearl;
style PageNo from TitlesAndFooters /
pretext = " "
posttext = " "
cellpadding=0
cellspacing=0
just=c /* Center */
vjust=b /* Bottom */;
end;
run;
ods _all_ close;
options papersize=a4 orientation=portrait leftmargin=3cm rightmargin=1.5cm topmargin=1.5cm bottommargin=1.5cm nodate;
ods pdf file="&yourpath.\Loop.pdf" style=move;
%Testloop;
ods pdf close;
... View more