Proc Report and special character - sas

I would like to use proc report in SAS .
My code is :
define email/display style(column)={cell width=500}
I would like display email address. In output I haven't got # sign.
Please help me.

Check what you have set as the SPLIT= character on the PROC statement.
Example:
data test;
email='user#host';
run;
proc report data=test split='#';
title1 "Split='#'";
define email / flow ;
run;
proc report data=test ;
title1 "No SPLIT= option";
define email / flow ;
run;
Listing output:
Split='#'
email
user
host
No SPLIT= option
email
user#host

Related

Regression results returning 0 in SAS Enterprise Guide

I am brand new to SAS . I'm trying to create dummy variables in SAS and run regression. After doing some research, I put the following codes together, but the results are showing 0 for a few Col. Does anyone know how to fix this? Thanks !
proc glmmod data = Work.Cost outdesign= GLMDesign outparm=GLMParm;
class sex age Membership; model amount=sex age ;
run;
proc print data=GLMDesign ; run; proc print data=GLMParm ; run;
proc reg data=GLMDesign; DummyVars: model amount = COL1-COL69; ods select ParameterEstimates;
quit;

proc report print null dataset

I have a null dataset such as
data a;
if 0;
run;
Now I wish to use proc report to print this dataset. Of course, there will be nothing in the report, but I want one sentence in the report said "It is a null dataset". Any ideas?
Thanks.
You can test to see if there are any observations in the dataset first. If there are observations, then use the dataset, otherwise use a dummy dataset that looks like this and print it:
data use_this_if_no_obs;
msg = 'It is a null dataset';
run;
There are plenty of ways to test datasets to see if they contain any observations or not. My personal favorite is the %nobs macro found here: https://stackoverflow.com/a/5665758/214994 (other than my answer, there are several alternate approaches to pick from, or do a google search).
Using this %nobs macro we can then determine the dataset to use in a single line of code:
%let ds = %sysfunc(ifc(%nobs(iDs=sashelp.class) eq 0, use_this_if_no_obs, sashelp.class));
proc print data=&ds;
run;
Here's some code showing the alternate outcome:
data for_testing_only;
if 0;
run;
%let ds = %sysfunc(ifc(%nobs(iDs=for_testing_only) eq 0, use_this_if_no_obs, sashelp.class));
proc print data=&ds;
run;
I've used proc print to simplify the example, but you can adapt it to use proc report as necessary.
For the no data report you don't need to know how many observations are in the data just that there are none. This example shows how I would approach the problem.
Create example data with zero obs.
data class;
stop;
set sashelp.class;
run;
Check for no obs and add one obs with missing on all vars. Note that no observation are every read from class in this step.
data class;
if eof then output;
stop;
modify class end=eof;
run;
make the report
proc report data=class missing;
column _all_;
define _all_ / display;
define name / order;
compute before name;
retain_name=name;
endcomp;
compute after;
if not missing(retain_name) then l=0;
else l=40;
msg = 'No data for this report';
line msg $varying. l;
endcomp;
run;

PROC REPORT within DATA in SAS

I am trying to do a simple thing - write a PROC REPORT procedure within a DATA sentence. My main idea is - if the condition in data step is true - lets execute PROC REPORT, if it is false - do not execute PROC REPORT. Any ideas? Code runs without errors for now, but I see that condition in IF statement is not applied and PROC REPORT is ececute despite the fact that condition is not fulfilled.
Thank you in Advance.
%let DATO = 13062016;
PROC IMPORT OUT= WORK.auto1 DATAFILE= "C:\Users\BC1554\Desktop\andel.xlsx"
DBMS=xlsx REPLACE;
SHEET="sheet1";
GETNAMES=YES;
RUN;
data want;
set WORK.auto1;
rownum=_n_;
run;
DATA tbl2;
SET want;
if (rownum => 1 and rownum <=6 ) then output work.tbl2 ;
RUN;
ODS NORESULTS;
ods LISTING close;
ODS RTF FILE="C:\Users\BC1554\Desktop\Statistik_andel_&DATO..rtf";
title "Statistics from monthly run of DK shares of housing companies (andelsboliger)";
data Tbl21 ;
set work.Tbl2;
where (DKANDEL='Daekning_pct_24052016' or DKANDEL='Daekning_pct_18042016') ;
difference = dif(Andel);
difference1 = dif(Total);
run;
data Tbl211 ;
set work.Tbl21;
where (DKANDEL='Daekning_pct_18042016') ;
run;
data Tbl2111 ;
set work.Tbl211;
where (DKANDEL='Daekning_pct_18042016') ;
if abs(difference) > 10 and abs (difference1) > 107 then ;
run;
proc report data= work.Tbl2 spanrows;
columns DKANDEL Andel Total Ukendt ;
title2 "-";
title3 "We REPORT numbers on p.4-5".;
title4 "-";
title5 "The models coverage";
title6 "Run date &DATO.";
footnote1 "Assets without currency code not included";
define DKANDEL / order;
define Andel / order;
define Total / order;
define Ukendt / order;
define DKANDEL/ display;
define Andel / display;
Compute DKANDEL;
call define (_col_,"style","style={background=orange}");
endcomp;
Compute Andel;
call define (_col_,"style","style={background=red}");
endcomp;
run; title; footnote1;
ODS RTF close;
ODS LISTING;
title;
run;
To conditionally execute code you need to use a macro so that you can use macro logic like %IF to conditionally generate the code.
But for your simple problem you can use a macro variable to modify the RUN; statement on your PROC REPORT step. Create a macro variable and set it to the value CANCEL when you don't want the step to run.
%let cancel=CANCEL;
...
if abs(difference) > 10 and abs (difference1) > 107 then call symputx('cancel','');
...
proc report ... ;
...
run &cancel ;
Simple example. Produce report if anyone is aged 13.
%let cancel=CANCEL;
data _null_;
set sashelp.class ;
if age=13 then call symputx('cancel',' ');
run;
proc report data=sashelp.class ;
run &cancel;
Tom's answer is a good one, and probably what I'd do. But, an alternative that is more exactly what you suggested in the question seems also appropriate.
The way you execute a PROC REPORT in a data step (or execute any non-data-step code in a data step) is with call execute. You can use call execute to execute a macro, or just a string of code; up to you how you want to handle it. I would make it a macro, because that makes development much easier (you can write the macro just like regular code, and you can test it independently).
Here's a simple example that is analogous to what Tom put in his answer.
%macro print_report(data=);
proc report data=&data.;
run;
%mend print_report;
data _null_;
set sashelp.class ;
if age=13 then do;
call execute('%print_report(data=sashelp.class)');
stop; *prevent it from donig this more than once;
end;
run;

SAS Ods RTF and PROC REPORT

So I've writen this:
ods rtf file = "D:\Sarath\List\2.rtf";
proc report data = list.lst1;
column PATIENT EOSDT STDRUG STDRUGSP STDCOMP STDCOMSP DAY5 EOSREAS;
define PATIENT/display "Subject * Number";
define EOSDT /order "Date of * Study Completion/ * Early Discontinuation";
define STDRUG/order "Administered*Study Drug?";
define STDRUGSP/display "If no,*Specify" ;
define STDCOMP/order "Completed*Dosing";
define STDCOMSP/display "If no,*Specify";
define DAY5/order "Completed*Study?";
define EOSREAS/display "Reason for * not Completing";
run;
ods rtf close;
and it creates an rtf with no data. Just a blank page. Please tell me what am I doing wrong here.
Regards.
Add nowd to the proc report line, otherwise SAS is expecting proc report to be an interactive procedure.
proc report data = list.lst1 nowd;
See documentation here:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473620.htm

SAS - Proc Report headline option issue

When I run the code below, it outputs a text file where the default hyphen for the headline option is replaced by the letter F. So I get a series of Fs dispayed across my report. Any idea what could be causing this? I've never run across this before and can't find any info about it...
proc printto print='c:\temp\test.txt';
run;
PROC REPORT DATA=SUM_2010 HEADLINE HEADSKIP MISSING nowd;
COLUMNS field1 field2;
DEFINE field1 / 'NUMBER OF things' FORMAT=COMMA20.0 WIDTH=25;
DEFINE filed2 / 'VALUE of things' FORMAT=DOLLAR28.2 WIDTH=30;
RBREAK AFTER/SKIP SUMMARIZE DOL;
TITLE1 "something";
TITLE2 "something something";
TITLE3 "more something";
TITLE4 "YEAR: 2010";
RUN;
quit;
Try the formchar option - this affects horizontal and vertical lines in proc tabulate and proc report. This should provide more appealing output => options formchar="|----||---|-/\<>*"; (run it before the proc report).