BookmarkSubscribeRSS Feed
Nooby1Konoby
Calcite | Level 5
I'm attempting to send an ODS ni HTML format. I'm computing a var and then using that computed var in my HTML code, however i can not figure out why in the HTML portion of the code it is giving me Var not found below is my code does anyone have any thoughts? I've check most doco but can't find anything

PROC REPORT DATA=MAP HEADLINE NOWD;

COLUMN CONTRACT VOLCAPGB REMAINING;

DEFINE CONTRACT / GROUP;
DEFINE VOLCAPGB / SUM;
DEFINE REMAINING / COMPUTED;

COMPUTE REMAINING;
REMAINING=(CONTRACT - VOLCAPGB.SUM);
ENDCOMP;
TITLE 'REMAINING GIGABYTES AT DRP' &SYSDATE;


FILENAME HTMLOUT 'DSM.DASD.CAP.TOTALS1' DISP=(MOD)
RECFM=VB LRECL=20004 BLKSIZE=27998 UNIT=3390 SPACE=(CYL,(1,2));

ODS HTML FILE=HTMLOUT RS=NONE STYLE=MINIMAL;
PROC PRINT SPLIT='_' NOOBS WIDTH=MIN DATA=MAP;

VAR CONTRACT/STYLE(COLUMN)={HTMLSTYLE="MSO=GENERAL-FORMAT:@"};
VAR VOLCAPGB/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
VAR REMAINING/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
RUN;
ODS HTML CLOSE;


ERROR From SASLOG

47 VAR CONTRACT/STYLE(COLUMN)={HTMLSTYLE="MSO=GENERAL-FORMAT:@"};
48 VAR VOLCAPGB/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
49 VAR REMAINING/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
ERROR: Variable REMAINING not found.
ERROR: Variable REMAINING not found.
ERROR: Variable REMAINING not found.
50 TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
51 RUN;
6 REPLIES 6
Robert_Bardos
Fluorite | Level 6
Well, I'd say the error message originates from PROC PRINT where you try to list the non-existing variable REMAINING. The compute block in PROC REPORT does not add the variable to the dataset permanently. So if you want the variable in PROC PRINT as well you will have to add it by means of a data step.
Cynthia_sas
SAS Super FREQ
Hi:
I agree with Robert -- PROC REPORT is operating on WORK.MAP. You do NOT create a dataset with PROC REPORT in your code. PROC PRINT is operating on WORK.MAP -- and since REMAINING is a COMPUTED report item (NOT a dataset variable), it does not exist in WORK.MAP. PROC REPORT does not alter the INPUT dataset -- it merely computes an item on every report row.

Now, you can create a dataset from PROC REPORT (using the OUT= option) OR you could simply move the PROC REPORT code into the ODS HTML "sandwich" instead of the PROC PRINT code. The same HTMLSTYLE override that you use in PROC PRINT could be used in your DEFINE statements for PROC REPORT something like this:
[pre]
FILENAME HTMLOUT 'DSM.DASD.CAP.TOTALS1' DISP=(MOD)
RECFM=VB LRECL=20004 BLKSIZE=27998 UNIT=3390 SPACE=(CYL,(1,2));

ods msoffice2k file=htmlout rs=none style=minimal;
PROC REPORT DATA=MAP NOWD split='_';

COLUMN CONTRACT VOLCAPGB REMAINING;

DEFINE CONTRACT / GROUP
STYLE(COLUMN)={HTMLSTYLE="MSO-GENERAL-FORMAT:@"};
DEFINE VOLCAPGB / SUM
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
DEFINE REMAINING / COMPUTED
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
COMPUTE REMAINING;
REMAINING=(CONTRACT - VOLCAPGB.SUM);
ENDCOMP;
TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
run;
ods _all_ close;
[/pre]

Do note that I changed from ODS HTML to ODS MSOFFICE2K -- I find that Excel is generally happier with Microsoft "flavor" of HTML tags, such as that created by the MSOFFICE2K destination. If, however, you are still running SAS 8, then ODS HTML creates HTML 3.2 "flavor" of HTML tags -- which Excel is fairly happy with. In SAS 9, however, ODS HTML creates HTML 4.0 "flavor" of HTML tags --and Excel is generally not happy with HTML 4.0 tags and inline <STYLE> section.

cynthia
Nooby1Konoby
Calcite | Level 5
Thank you both for the feed back; I Coded it as you suggested Cynthia and that corrected my Var error, now to figure out why it is not printing 🙂 thanks again for the help. Cheers
Cynthia_sas
SAS Super FREQ
Hi:
In your original program flow, you had:
[pre]
...PROC REPORT step

FILENAME statement

ODS HTML ...;
...PROC PRINT step
ODS HTML CLOSE;
[/pre]

I'm not sure what you mean by "printing", but IF you changed your code to be like the code block that I put in my post, then I would suggest that you do two things to make sure that ODS LISTING is explicitly turned ON:
[pre]
FILENAME statement

ods listing; /* makes sure that ODS LISTING is turned on here */

ODS msoffice2k ...;
...PROC REPORT step
ODS _all_ CLOSE;

ods listing; /* turns ODS LISTING back on after close with _ALL_ */
[/pre]

If ODS LISTING is closed before the PROC REPORT step that I posted, then nothing will go to the LISTING window (if you can print from your LISTING window). The ODS _ALL_ CLOSE statement that I used will CLOSE the LISTING window as well as all open destinations. If you were submitting your code in a batch job, and it was ONLY the one step, then there would have not been a side effect from the ODS _ALL_ CLOSE. However, if you had steps underneath the PROC REPORT step, then ODS _ALL_ CLOSE would have closed the LISTING window and nothing would have gone to the LISTING destination. Sorry -- I just forgot to put ODS LISTING; after the ODS _ALL_ CLOSE;

So, depending on what you mean by "printing", try adding some ODS LISTING; statements into your code, in addition to the other ODS statements and see whether that helps.

cynthia
Nooby1Konoby
Calcite | Level 5
Cynthia thanks again for the assistance. I'm very new to SAS and I think i'm shooting myself in the foot. The job i've created is a mainframe batch job, it has 4 different SAS steps that pull in raw data from several exteral datasets. the first two steps work fine and produce output in HTML format; its the last two steps (that you've helped with) that are not producing any output. I'm just at a lose below is the entire job, if you find anything that jumps out at you the help would be appreciated, if you don't have the time to look at it i understand, thanks again for the support

//JS001 EXEC SAS
//*INCL DD DISP=SHR,DSN=T35.SM.REPORT.MACROS
//DASDCP DD DSN=DSM.STORAGE.CAP.CONFIG,DISP=SHR
// DD DSN=DSM.STORAGE.TPLXCAP.CONFIG,DISP=SHR
// DD DSN=DSM.STORAGE.DPLXCAP.CONFIG,DISP=SHR
//SASLIST DD DSN=DSM.DASD.CAP.REPORT,DISP=OLD
//* SPACE=(CYL,(5,2),RLSE),DCB=(RECFM=FB,LRECL=133)
//SYSIN DD *
OPTIONS NOCENTER;

DATA ALL;
INFILE DASDCP;
INPUT @1 VOLSER $CHAR6. @8 UNIT $ @17 CAP 6.1;

FORMAT CAP AVAL 5.;


DATA CAP;
SET ALL;

IF UNIT = :'2'
THEN SUBSYSTEM = '2107#1';
ELSE IF UNIT = :'C'
THEN SUBSYSTEM = '2107#1';
ELSE IF UNIT = :'4'
THEN SUBSYSTEM = '2107#2';
ELSE IF UNIT = :'5'
THEN SUBSYSTEM = '2107#2';
ELSE IF UNIT = :'3'
THEN SUBSYSTEM = '2107#3';
ELSE IF UNIT = :'9'
THEN SUBSYSTEM = '2107#3';
ELSE IF UNIT = :'D'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E4'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E5'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E6'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E7'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E8'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E9'
THEN SUBSYSTEM = '2107#4';
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'EB'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'EC'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'ED'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'EE'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'EF'
THEN SUBSYSTEM = '2107#4';
ELSE IF UNIT = :'E0'
THEN SUBSYSTEM = '#4TPLX';
ELSE IF UNIT = :'E1'
THEN SUBSYSTEM = '#4TPLX';
ELSE IF UNIT = :'E2'
THEN SUBSYSTEM = '#4ZVM ';
ELSE IF UNIT = :'E3'
THEN SUBSYSTEM = '#4ZVM ';
ELSE IF UNIT = :'A'
THEN SUBSYSTEM = '2107#5';
ELSE IF UNIT = :'B'
THEN SUBSYSTEM = '2107#5';

DATA AVAL;
SET CAP;

IF VOLSER = :'XT'
THEN AVAL = CAP;


PROC REPORT DATA = AVAL;
COLUMN SUBSYSTEM CAP AVAL;

DEFINE SUBSYSTEM / GROUP;
DEFINE CAP / SUM;
DEFINE AVAL / SUM;
//JS002 EXEC SAS
//INCL DD DISP=SHR,DSN=T35.SM.REPORT.MACROS
//DASDSM DD DSN=DSM.DASD.CAP.REPORT,DISP=SHR
//SASLIST DD DSN=DSM.DASD.CAP.REPORT1,DISP=OLD
//* SPACE=(CYL,(5,5),RLSE),DCB=(RECFM=FB,LRECL=133)
//SYSIN DD *
OPTIONS NOCENTER;

DATA SUM;
INFILE DASDSM;


INPUT @3 SUBSYS $ @11 CAP 4.2 @18 AVAL 4.2;


IF _N_ =1 THEN DELETE;
IF _N_ =2 THEN DELETE;
IF _N_ =3 THEN DELETE;


IF _N_ =4 THEN DO;
PUT @1 "SUBSYS"
@10 "CAP/TB"
@19 "ALLOC/TB"
@30 "AVAL/TB"
/@1 "-----------------------------------";
END;
IF SUBSYS = :'#4TPLX' THEN DO;
ALLOC = CAP - AVAL;
END;
IF SUBSYS = :'2107' THEN DO;
ALLOC = CAP - AVAL;
END;
IF SUBSYS = :'-TPLX' THEN DO;
ALLOC = CAP - AVAL;
END;
IF SUBSYS = :'GSD1' THEN DO;
ALLOC = CAP - AVAL;
END;

IF SUBSYS = :'#4ZVM ' THEN DO;
ALLOC = CAP - AVAL;
END;

PUT @1 SUBSYS
@10 CAP
@19 ALLOC
@30 AVAL;

FILENAME HTMLOUT 'DSM.DASD.CAP.TOTALS1' DISP=(OLD)
RECFM=VB LRECL=20004 BLKSIZE=27998 UNIT=3390 SPACE=(CYL,(1,2));

ODS LISTING;

ODS HTML FILE=HTMLOUT RS=NONE STYLE=MINIMAL;
PROC PRINT SPLIT='_' NOOBS WIDTH=MIN DATA= SUM;

VAR SUBSYS/STYLE(COLUMN)={HTMLSTYLE="MSO=GENERAL-FORMAT:@"};
VAR CAP/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
VAR ALLOC/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
VAR AVAL/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};

SUM CAP ALLOC AVAL/
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
RUN;
ODS HTML CLOSE;

ODS LISTING;
//JS003 EXEC SAS
//VOLMAP DD DSN=DSM.ADSMD010.DRP.VOLUME.MAP,DISP=SHR
//* DD DSN=DSM.STORAGE.DRP.CONFIG,DISP=SHR
// DD DSN=DSM.STORAGE.DRP.SYSVOL.CONFIG,DISP=SHR
//SASLIST DD DSN=DSM.DASD.DRP.REPORT,
// DISP=OLD
//* SPACE=(CYL,(5,2),RLSE),DCB=(RECFM=FB,LRECL=133)
//SYSIN DD *
OPTIONS NOCENTER;

DATA MAP;
INFILE VOLMAP;
INPUT @1 VOLSER $CHAR6. @18 MOD $CHAR7.;

IF MOD = '3390-29' THEN MOD = '3390-27';
IF MOD = '3390-54' THEN VOLCAPGB = 55.68;
ELSE
IF MOD = '3390-27' THEN VOLCAPGB = 27;
ELSE
IF MOD = '3390-9 ' THEN VOLCAPGB = 8;
ELSE
IF MOD = '3390-3 ' THEN VOLCAPGB = 2.84;
ELSE
IF VOLSER = :'FC' THEN VOLCAPGB = 27;
IF VOLSER = :'FC' THEN DO
MOD = 'FCVOLS';
END;
IF VOLSER =:'SYS' THEN VOLCAPGB = 27;
IF VOLSER =:'SYS' THEN DO
MOD = '3390-27';
END;

FORMAT VOLCAPGB BEST;
PROC SORT; BY MOD;
PROC SUMMARY; BY MOD; VAR VOLCAPGB;
OUTPUT OUT = CAPDATA N=NVOLS SUM=VOLCAPGB;

PROC PRINT NOOBS;
SUM NVOLS VOLCAPGB;
VAR MOD NVOLS VOLCAPGB;
TITLE 'TOTAL NUMBER OF VOLUMES NEED FOR DRP' &SYSDATE;

FILENAME HTMLOUT 'DSM.DASD.CAP.TOTALS1' DISP=(MOD)
RECFM=VB LRECL=20004 BLKSIZE=27998 UNIT=3390 SPACE=(CYL,(1,2));

ODS LISTING;

ODS HTML FILE=HTMLOUT RS=NONE STYLE=MINIMAL;
PROC PRINT SPLIT='_' NOOBS WIDTH=MIN DATA=CAPDATA;

VAR MOD/STYLE(COLUMN)={HTMLSTYLE="MSO=GENERAL-FORMAT:@"};
VAR NVOLS/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
VAR VOLCAPGB/STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
SUM NVOLS VOLCAPGB/
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
RUN;
ODS HTML CLOSE;

ODS LISTING;
/*
//JS004 EXEC SAS
//VOLMAP DD DSN=DSM.ADSMD010.DRP.VOLUME.MAP,DISP=SHR
//* DD DSN=DSM.STORAGE.DRP.CONFIG,DISP=SHR
// DD DSN=DSM.STORAGE.DRP.SYSVOL.CONFIG,DISP=SHR
//SASLIST DD DSN=DSM.DASD.DRP.REPORT,
// DISP=MOD
//* SPACE=(CYL,(5,2),RLSE),DCB=(RECFM=FB,LRECL=133)
//SYSIN DD *
OPTIONS NOCENTER;

DATA MAP;
INFILE VOLMAP;
INPUT @1 VOLSER $CHAR6. @18 MOD $CHAR7.;
CONTRACT = 163000;


IF MOD = '3390-29' THEN MOD = '3390-27';
IF MOD = '3390-54' THEN VOLCAPGB = 55.68;
ELSE
IF MOD = '3390-27' THEN VOLCAPGB = 27;
ELSE
IF MOD = '3390-9 ' THEN VOLCAPGB = 8;
ELSE
IF MOD = '3390-3 ' THEN VOLCAPGB = 2.84;
ELSE
IF VOLSER = :'FC' THEN VOLCAPGB = 27;
IF VOLSER = :'FC' THEN DO
MOD = 'FCVOLS';
END;
IF VOLSER =:'SYS' THEN VOLCAPGB = 27;
IF VOLSER =:'SYS' THEN DO
MOD = '3390-27';
END;

FILENAME HTMLOUT 'DSM.DASD.CAP.TOTALS1' DISP=(MOD)
RECFM=VB LRECL=20004 BLKSIZE=27998 UNIT=3390 SPACE=(CYL,(1,2));

ODS LISTING;

ODS HTML FILE=HTMLOUT RS=NONE STYLE=MINIMAL;
PROC REPORT DATA=MAP NOWD SPLIT='_';

COLUMN CONTRACT VOLCAPGB REMAINING;

DEFINE CONTRACT / GROUP
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
DEFINE VOLCAPGB / SUM
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};

DEFINE REMAINING / COMPUTED
STYLE(COLUMN)={HTMLSTYLE="MSO-NUMBER-FORMAT:@"};
COMPUTE REMAINING;
REMAINING=(CONTRACT - VOLCAPGB.SUM);
ENDCOMP;

TITLE "TESTING EXCEL CAP REPORT &SYSDATE";
RUN; ODS _ALL_ CLOSE;

ODS LISTING;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
It would be most helpful if you shared the SAS-generated log for the step(s) involved with whatever problem you're having.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 949 views
  • 0 likes
  • 4 in conversation