BookmarkSubscribeRSS Feed
d6k5d3
Pyrite | Level 9

The following code snippet is giving me the following NOTE and ERROR:

 

NOTE: Table has been opened in browse mode.
ERROR: Asterisks are an indication of a format width problem.

 

%macro cb_summary (cur, reg, code);

proc means data= &cur._c_&reg._&code. noprint;
class Event;
output out= S&cur._c_&reg._&code.;
run;

data S&cur._c_&reg._&code.;
set S&cur._c_&reg._&code.;

if _TYPE_= 1;
run;

%if &code.= 1 %then %do;
proc means data= &cur._c_&reg._&code. noprint;
class Event Year;
output out= YS&cur._c_&reg._&code.;
run;

data YS&cur._c_&reg._&code.;
set YS&cur._c_&reg._&code.;

if _TYPE_= 3;
run;
%end;

%mend cb_summary;

%cb_summary (HUF, HUN, 1);
%cb_summary (HUF, HUN, 2);
%cb_summary (HUF, US, 1);
%cb_summary (HUF, US, 2);

While the above code snippet gives the NOTE and ERROR in log, the following does not:

 

%macro eco_summary (cur, reg);

proc means data= &cur._E_&reg. noprint;
class Event;
output out= S&cur._E_&reg.;
run;

data S&cur._E_&reg.;
set S&cur._E_&reg.;

if _TYPE_= 1;
run;

proc means data= &cur._E_&reg. noprint;
class Event Year;
output out= YS&cur._E_&reg.;
run;

data YS&cur._E_&reg.;
set YS&cur._E_&reg.;

if _TYPE_= 3;
run;

%mend eco_summary;

%eco_summary (HUF, HUN);
%eco_summary (HUF, US);

I am sorry I fail to figure out. Need help!

 

Much thanks.

9 REPLIES 9
LinusH
Tourmaline | Level 20
No idea really.
While debugging macro options symbolgen MPRINT mlogic is your friends.
Can it be a locking issue, like you run in EG and result opens automatically.
Data never sleeps
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

do you have the %if test outside of a datastep?

d6k5d3
Pyrite | Level 9
It's right before a PROC MEANS step.
Astounding
PROC Star

Regardless of what the answer turns out to be, you should learn the NWAY option on the PROC MEANS statement.  The output data set would contain only the most detailed level of summarization automatically, and you would not need the DATA step that follows either PROC MEANS.

d6k5d3
Pyrite | Level 9
Thanks so much! 🙂 I was really looking forward to something like this! 🙂 I love the way I learn things here!
Shmuel
Garnet | Level 18

Can you post the full log ?

Regarding the ERROR "ERROR: Asterisks are an indication of a format width problem." -

1) Which dataset and which variablr does it relate to ?

2) Open that (or look for) dataset where variable is shown as '******' instead of a valid numeric value.

    That variable is assigned with too short format, for example run next code:

data check;
     num=123456;
    format num 4.;
put num=; run;

  maybe the asterisk relates to a summary that needs more positions than any value summed:

data check;
    num1 = 27;
    num2 = 36;
    num3 = 59;
    
    sum = sum(num1, num2, num3);
    put sum 2.;
run;

 

 

d6k5d3
Pyrite | Level 9
I think I should have mentioned this earlier. I apologize. The NOTE and ERROR that I receive in the log appears only after I double-click the result datsets to view them.
Shmuel
Garnet | Level 18

Mainly there is no error in your code.

 

You can eliminate the error-note either by changing the format in your input datasets of the related variables or

by adding a format statement in the proc means:

    proc means ...;

       class ... ;

       var .....;

      output .... ;

      FORMAT <variables> <wide enough format. >;

  run;

d6k5d3
Pyrite | Level 9

The log for your reference:

 

1062  %macro cb_summary (cur, reg, code);
1063
1064  proc means data= &cur._c_&reg._&code. nway noprint;
1065  class Event;
1066  output out= S&cur._c_&reg._&code.;
1067  run;
1068
1069  /*data S&cur._c_&reg._&code.;
1070  set S&cur._c_&reg._&code.;
1071
1072  if _TYPE_= 1;
1073  run;*/
1074
1075  %if &code.= 1 %then %do;
1076  proc means data= &cur._c_&reg._&code. nway noprint;
1077  class Event Year;
1078  output out= YS&cur._c_&reg._&code.;
1079  run;
1080
1081  /*data YS&cur._c_&reg._&code.;
1082  set YS&cur._c_&reg._&code.;
1083
1084  if _TYPE_= 3;
1085  run;*/
1086  %end;
1087
1088  %mend cb_summary;
1089
1090  options mprint;
1091
1092  %cb_summary (HUF, HUN, 1);
MPRINT(CB_SUMMARY):   proc means data= HUF_c_HUN_1 nway noprint;
MPRINT(CB_SUMMARY):   class Event;
MPRINT(CB_SUMMARY):   output out= SHUF_c_HUN_1;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_HUN_1.
NOTE: The data set WORK.SHUF_C_HUN_1 has 5 observations and 28 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.83 seconds
      cpu time            0.39 seconds


MPRINT(CB_SUMMARY):   proc means data= HUF_c_HUN_1 nway noprint;
MPRINT(CB_SUMMARY):   class Event Year;
MPRINT(CB_SUMMARY):   output out= YSHUF_c_HUN_1;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_HUN_1.
NOTE: The data set WORK.YSHUF_C_HUN_1 has 60 observations and 28 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.37 seconds
      cpu time            0.46 seconds


1093  %cb_summary (HUF, HUN, 2);
MPRINT(CB_SUMMARY):   proc means data= HUF_c_HUN_2 nway noprint;
MPRINT(CB_SUMMARY):   class Event;
MPRINT(CB_SUMMARY):   output out= SHUF_c_HUN_2;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_HUN_2.
NOTE: The data set WORK.SHUF_C_HUN_2 has 10 observations and 16 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.56 seconds
      cpu time            0.28 seconds


1094  %cb_summary (HUF, US, 1);
MPRINT(CB_SUMMARY):   proc means data= HUF_c_US_1 nway noprint;
MPRINT(CB_SUMMARY):   class Event;
MPRINT(CB_SUMMARY):   output out= SHUF_c_US_1;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_US_1.
NOTE: The data set WORK.SHUF_C_US_1 has 10 observations and 29 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.83 seconds
      cpu time            0.36 seconds


MPRINT(CB_SUMMARY):   proc means data= HUF_c_US_1 nway noprint;
MPRINT(CB_SUMMARY):   class Event Year;
MPRINT(CB_SUMMARY):   output out= YSHUF_c_US_1;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_US_1.
NOTE: The data set WORK.YSHUF_C_US_1 has 70 observations and 29 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.38 seconds
      cpu time            0.45 seconds


1095  %cb_summary (HUF, US, 2);
MPRINT(CB_SUMMARY):   proc means data= HUF_c_US_2 nway noprint;
MPRINT(CB_SUMMARY):   class Event;
MPRINT(CB_SUMMARY):   output out= SHUF_c_US_2;
MPRINT(CB_SUMMARY):   run;

NOTE: There were 841896 observations read from the data set WORK.HUF_C_US_2.
NOTE: The data set WORK.SHUF_C_US_2 has 10 observations and 16 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.55 seconds
      cpu time            0.28 seconds



NOTE: Table has been opened in browse mode.
ERROR: Asterisks are an indication of a format width problem.
ERROR: Asterisks are an indication of a format width problem.
ERROR: Asterisks are an indication of a format width problem.
ERROR: Asterisks are an indication of a format width problem.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 1425 views
  • 2 likes
  • 5 in conversation