BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
narnia649
Obsidian | Level 7

Hello,

 

Question:

How do I get href to display different per by variable group using the PROC SHEWHARTS & TABLE= option?

 

I am struggling to get a separate HREF to occur per by variable when using the PROC SHEWHARTS & TABLE option.

I can get it to work if I use DATA instead of TABLE.

 

My fake data below shows 3 grouping variables (X1-X3), a measurement (X4), a unique value that represents the combination of X1-X3 & a sequential time for each group. 

 

When I use, DATA=my_process, it works exactly as I want. It outputs the control charts with reference lines based on the _REF_ variable inside the href_data data table. For example, when x1=a, x2=b, x3= b or abb combination, the href is drawn at time step 3 as outlined by the href_data.

 

narnia649_0-1600719676984.png

 

However, when I output the data as a table and run PROC SHEWHART TABLE = my_process_tbl, I get a Warning message: "No match between the values of _VAR_ in MY_PROCESS_TBL and one or more process variable
names."

 

What do I have to change in the my_process_tbl to get the href to work again?

 

 

DATA my_process;
INPUT x1 $ x2 $ x3 $ x4 group time;
DATALINES;
a a a 1 1 1
a a a 2 1 2
a a a 1 1 3
a a a 3 1 4
a a b 1 2 1
a a b 4 2 2
a a b 5 2 3
a a b 6 2 4
a b a 3 3 1
a b a 2 3 2
a b a 1 3 3
a b a 10 3 4
a b b 4 4 1
a b b 0 4 2
a b b 5 4 3
a b b 15 4 4
b a a 2 5 1
b a a 2 5 2
b a a 2 5 3
b a a 2 5 4
b a b 1 6 1
b a b 1 6 2
b a b 1 6 3
b a b 1 6 4
b b a 5 7 1
b b a 5 7 2
b b a 5 7 3
b b a 5 7 4
b b b 4 8 1
b b b 4 8 2
b b b 4 8 3
b b b 4 8 4
;
RUN;

DATA href_data;
INPUT x1 $ x2 $ x3 $ _REF_;
DATALINES;
a a a 1
a a b 1
a b a 1
a b b 3
b a a 4
b a b 2
b b a 2
b b b 3
;
RUN;

PROC SHEWHART DATA = my_process; BY x1 x2 x3;
	IRCHART x4*time / href= href_data outlimits = my_process_lims outtable = my_process_tbl;
RUN;

PROC SHEWHART TABLE = my_process_tbl;
BY x1 x2 x3;
IRCHART _SUBI_*time / href = href_Data;
RUN;

Thanks in advance for your help on this!

 

1 ACCEPTED SOLUTION

Accepted Solutions
narnia649
Obsidian | Level 7

Thanks Reeza, your comment got me thinking more about what to set _VAR_ to and I was able to figure it out.

The out table no longer had x4 in it, so I had to create a new column with x4 that _VAR_ in my_process_tbl could reference.

Next, I had to add a _VAR_ column in href_data that contains x4 for each row.

And that did the trick!

 

The working code is below:

/* HREF Data Table Test */

*Closes html results;
ods html close;

*DM Submits a SAS statement to the Program Editor, Log, or Procedure Output;
dm log "OUT; CLEAR; LOG; CLEAR;" log continue;
dm log 'next results; clear; cancel;' whostedit continue;

*Creates a new html result;
ods html newfile=none;

%LET data_loc = C:\Users\NAOG\Desktop\Projects\Weekly CC Alerts\Add Vertical Line PROC SHEWART;
LIBNAME mylib "&data_loc";


DATA my_process;
INPUT x1 $ x2 $ x3 $ x4 group time;
DATALINES;
a a a 1 1 1
a a a 2 1 2
a a a 1 1 3
a a a 3 1 4
a a b 1 2 1
a a b 4 2 2
a a b 5 2 3
a a b 6 2 4
a b a 3 3 1
a b a 2 3 2
a b a 1 3 3
a b a 10 3 4
a b b 4 4 1
a b b 0 4 2
a b b 5 4 3
a b b 15 4 4
b a a 2 5 1
b a a 2 5 2
b a a 2 5 3
b a a 2 5 4
b a b 1 6 1
b a b 1 6 2
b a b 1 6 3
b a b 1 6 4
b b a 5 7 1
b b a 5 7 2
b b a 5 7 3
b b a 5 7 4
b b b 4 8 1
b b b 4 8 2
b b b 4 8 3
b b b 4 8 4
;
RUN;

DATA href_data;
INPUT x1 $ x2 $ x3 $ _REF_;
DATALINES;
a a a 1
a a b 1
a b a 1
a b b 3
b a a 4
b a b 2
b b a 2
b b b 3
;
RUN;

PROC SHEWHART DATA = my_process; BY x1 x2 x3;
	IRCHART x4*time / href= href_data outlimits = my_process_lims outtable = my_process_tbl;
RUN;


DATA href_data;
INPUT x1 $ x2 $ x3 $ _REF_ _VAR_ $;
DATALINES;
a a a 1 x4
a a b 1 x4
a b a 1 x4
a b b 3 x4
b a a 4 x4
b a b 2 x4
b b a 2 x4
b b b 3 x4
;
RUN;

DATA my_process_tbl;
	SET  my_process_tbl;
	x4 = _SUBI_;
RUN;


PROC SHEWHART TABLE = my_process_tbl;
BY x1 x2 x3;
IRCHART x4*time / href = href_Data;
RUN;

View solution in original post

4 REPLIES 4
Reeza
Super User
Do you maybe need to include the _VAR_ in the href_data dataset?

narnia649
Obsidian | Level 7

I tried a few ways of setting _VAR_ in the href_data table, but none seemed to work. 

I still get the same error. 

 

What would you set the _VAR_ to?

narnia649
Obsidian | Level 7

Thanks Reeza, your comment got me thinking more about what to set _VAR_ to and I was able to figure it out.

The out table no longer had x4 in it, so I had to create a new column with x4 that _VAR_ in my_process_tbl could reference.

Next, I had to add a _VAR_ column in href_data that contains x4 for each row.

And that did the trick!

 

The working code is below:

/* HREF Data Table Test */

*Closes html results;
ods html close;

*DM Submits a SAS statement to the Program Editor, Log, or Procedure Output;
dm log "OUT; CLEAR; LOG; CLEAR;" log continue;
dm log 'next results; clear; cancel;' whostedit continue;

*Creates a new html result;
ods html newfile=none;

%LET data_loc = C:\Users\NAOG\Desktop\Projects\Weekly CC Alerts\Add Vertical Line PROC SHEWART;
LIBNAME mylib "&data_loc";


DATA my_process;
INPUT x1 $ x2 $ x3 $ x4 group time;
DATALINES;
a a a 1 1 1
a a a 2 1 2
a a a 1 1 3
a a a 3 1 4
a a b 1 2 1
a a b 4 2 2
a a b 5 2 3
a a b 6 2 4
a b a 3 3 1
a b a 2 3 2
a b a 1 3 3
a b a 10 3 4
a b b 4 4 1
a b b 0 4 2
a b b 5 4 3
a b b 15 4 4
b a a 2 5 1
b a a 2 5 2
b a a 2 5 3
b a a 2 5 4
b a b 1 6 1
b a b 1 6 2
b a b 1 6 3
b a b 1 6 4
b b a 5 7 1
b b a 5 7 2
b b a 5 7 3
b b a 5 7 4
b b b 4 8 1
b b b 4 8 2
b b b 4 8 3
b b b 4 8 4
;
RUN;

DATA href_data;
INPUT x1 $ x2 $ x3 $ _REF_;
DATALINES;
a a a 1
a a b 1
a b a 1
a b b 3
b a a 4
b a b 2
b b a 2
b b b 3
;
RUN;

PROC SHEWHART DATA = my_process; BY x1 x2 x3;
	IRCHART x4*time / href= href_data outlimits = my_process_lims outtable = my_process_tbl;
RUN;


DATA href_data;
INPUT x1 $ x2 $ x3 $ _REF_ _VAR_ $;
DATALINES;
a a a 1 x4
a a b 1 x4
a b a 1 x4
a b b 3 x4
b a a 4 x4
b a b 2 x4
b b a 2 x4
b b b 3 x4
;
RUN;

DATA my_process_tbl;
	SET  my_process_tbl;
	x4 = _SUBI_;
RUN;


PROC SHEWHART TABLE = my_process_tbl;
BY x1 x2 x3;
IRCHART x4*time / href = href_Data;
RUN;
Reeza
Super User
Great, glad to hear you got it working and figured out how to specify it properly 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 964 views
  • 1 like
  • 2 in conversation