Hello,
I would like to insert a page number in my file print report that I create with a DATA step. Below is my code. Can someone please explain to me how to do it? Thank you, Aaron.
options missing='-';
title "Item Analysis Report for &FORM that has &NUMBER MCQs.";
DATA SCORED.&FORM.Combined_Statistics_R;
SET SCORED.&FORM.Combined_Statistics_R (RENAME=(Key_char=Key));
drop PValue_M Mean_Score_M PT_Biserial_M;
file print header=H linesleft=remain pagesize=90;
if remain<17 then put _page_ ;
PUT @1 "Item Number:" @14 seq @20 "Accession Number:" @38 ACN @55 "N of Response Opts:" @75 Number_of_Options/
@4 "Correct Answer:" @20 Key/
@4 'P Value:' @13 pvalue @21 'Pt Biserial:' @34 Pt_Biserial @42 "Bench Item Delta:" @60 Bench_Item_Delta //
@10 'Response Opt:' @30 "A" @40 "B" @50 "C" @60 "D" @70 "E" @80 "Missing" @90 'Total N of PPL'/
@10 'N of PPL:' @30 N_of_ppl_A @40 N_of_ppl_B @50 N_of_ppl_C @60 N_of_ppl_D @70 N_of_ppl_E @80 N_of_ppl_M @90 Total_N/
@10 'Opt P Value:' @30 PValue_A @40 PValue_B @50 PValue_C @60 PValue_D @70 PValue_E @80 /
@10 'Pt Biserial:' @30 PT_Biserial_A @40 PT_Biserial_B @50 PT_Biserial_C @60 PT_Biserial_D @70 PT_Biserial_E @80 /
@10 'Mean Score:' @30 Mean_Score_A @40 Mean_Score_B @50 Mean_Score_C @60 Mean_Score_D @70 Mean_Score_E @80 //
@4 "NOTE: For response options no examinee selects, a dash '-' is displayd for the Pt Biserial." /
@4 "NOTE: For a not permitted response option, a dash '-' is displayed for all item statistics."//;
return;
H: Put @1 "Item Analysis, &FORM, &NUMBER MCQs."/
@1 "Run Date: %sysfunc(date(),date9.)"/
@1 "Run Time: %sysfunc(time(),tod8.)"/;
RUN;
options missing='.';
title;
Maybe some thing like this:
missing='-'; title "Item Analysis Report for &FORM that has &NUMBER MCQs."; DATA SCORED.&FORM.Combined_Statistics_R; SET SCORED.&FORM.Combined_Statistics_R (RENAME=(Key_char=Key)); drop PValue_M Mean_Score_M PT_Biserial_M; file print header=H linesleft=remain pagesize=90; /* Establish a counter variable*/ Retain PageCount 1; if remain<17 then do; /*assuming this IF to page the file*/ Put Pagecount; put _page_ ; /*increment the counter after printing*/ PageCount+1; End; PUT @1 "Item Number:" @14 seq @20 "Accession Number:" @38 ACN @55 "N of Response Opts:" @75 Number_of_Options/ @4 "Correct Answer:" @20 Key/ @4 'P Value:' @13 pvalue @21 'Pt Biserial:' @34 Pt_Biserial @42 "Bench Item Delta:" @60 Bench_Item_Delta // @10 'Response Opt:' @30 "A" @40 "B" @50 "C" @60 "D" @70 "E" @80 "Missing" @90 'Total N of PPL'/ @10 'N of PPL:' @30 N_of_ppl_A @40 N_of_ppl_B @50 N_of_ppl_C @60 N_of_ppl_D @70 N_of_ppl_E @80 N_of_ppl_M @90 Total_N/ @10 'Opt P Value:' @30 PValue_A @40 PValue_B @50 PValue_C @60 PValue_D @70 PValue_E @80 / @10 'Pt Biserial:' @30 PT_Biserial_A @40 PT_Biserial_B @50 PT_Biserial_C @60 PT_Biserial_D @70 PT_Biserial_E @80 / @10 'Mean Score:' @30 Mean_Score_A @40 Mean_Score_B @50 Mean_Score_C @60 Mean_Score_D @70 Mean_Score_E @80 // @4 "NOTE: For response options no examinee selects, a dash '-' is displayed for the Pt Biserial." / @4 "NOTE: For a not permitted response option, a dash '-' is displayed for all item statistics."//; return; H: Put @1 "Item Analysis, &FORM, &NUMBER MCQs."/ @1 "Run Date: %sysfunc(date(),date9.)"/ @1 "Run Time: %sysfunc(time(),tod8.)"/; RUN; options missing='.'; title;
Without data there is not way to actually test this.
Corrected a spelling for "displayd" in the for Pt Biserial line.
Maybe some thing like this:
missing='-'; title "Item Analysis Report for &FORM that has &NUMBER MCQs."; DATA SCORED.&FORM.Combined_Statistics_R; SET SCORED.&FORM.Combined_Statistics_R (RENAME=(Key_char=Key)); drop PValue_M Mean_Score_M PT_Biserial_M; file print header=H linesleft=remain pagesize=90; /* Establish a counter variable*/ Retain PageCount 1; if remain<17 then do; /*assuming this IF to page the file*/ Put Pagecount; put _page_ ; /*increment the counter after printing*/ PageCount+1; End; PUT @1 "Item Number:" @14 seq @20 "Accession Number:" @38 ACN @55 "N of Response Opts:" @75 Number_of_Options/ @4 "Correct Answer:" @20 Key/ @4 'P Value:' @13 pvalue @21 'Pt Biserial:' @34 Pt_Biserial @42 "Bench Item Delta:" @60 Bench_Item_Delta // @10 'Response Opt:' @30 "A" @40 "B" @50 "C" @60 "D" @70 "E" @80 "Missing" @90 'Total N of PPL'/ @10 'N of PPL:' @30 N_of_ppl_A @40 N_of_ppl_B @50 N_of_ppl_C @60 N_of_ppl_D @70 N_of_ppl_E @80 N_of_ppl_M @90 Total_N/ @10 'Opt P Value:' @30 PValue_A @40 PValue_B @50 PValue_C @60 PValue_D @70 PValue_E @80 / @10 'Pt Biserial:' @30 PT_Biserial_A @40 PT_Biserial_B @50 PT_Biserial_C @60 PT_Biserial_D @70 PT_Biserial_E @80 / @10 'Mean Score:' @30 Mean_Score_A @40 Mean_Score_B @50 Mean_Score_C @60 Mean_Score_D @70 Mean_Score_E @80 // @4 "NOTE: For response options no examinee selects, a dash '-' is displayed for the Pt Biserial." / @4 "NOTE: For a not permitted response option, a dash '-' is displayed for all item statistics."//; return; H: Put @1 "Item Analysis, &FORM, &NUMBER MCQs."/ @1 "Run Date: %sysfunc(date(),date9.)"/ @1 "Run Time: %sysfunc(time(),tod8.)"/; RUN; options missing='.'; title;
Without data there is not way to actually test this.
Corrected a spelling for "displayd" in the for Pt Biserial line.
Hi:
You do NOT show your options, but I wonder why you are not using the simple options for inserting a page number. For example, in a much simplifed version of your program that only writes out from SASHELP.SHOES:
And even if you do not want to print your FILE PRINT report from the OUTPUT window, you can use the FILE= option of ODS LISTING to make an ASCII text file that contains "page feeds" and page numbers, as shown here:
the options number/nonumber and pageno= have been around for quite some time. I wouldn't expect you have to do your own page numbering under most circumstances.
cynthia
Thanks, but although it leads to page numbers, it doesn't provide the kind of solution I want.
@ADouglas wrote:
Thanks, but although it leads to page numbers, it doesn't provide the kind of solution I want.
When providing a short answer like that you may want to consider using the QUOTE button at the upper right of the message entry window so that we know which solution, question or comment you are addressing.
Thanks. This worked.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.