BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ChrisNZ
Tourmaline | Level 20

Hi,

Running this code

data T;
  retain X1SPACE X2SPACE 'datavalue' Y1SPACE Y2SPACE 'datapercent' FUNCTION 'line';
  X1=13; X2=15; Y1=25; Y2=50; output;
  X1=11; X2=13; Y1SPACE ='datavalue'; Y2SPACE ='datavalue'; YC1='Alice'; YC2='Alice'; output;
run;  
proc sgplot data=SASHELP.CLASS sganno=T; 
  scatter x=AGE y=NAME;
run;
results in only one line being drawn, and message:

WARNING: DrawLine statement has missing/invalid value for position (X or Y). Draw statement discarded.

Removing any one of the 2 output lines in the data step results in the remaining line being drawn without issue.
How can I mix referentials (or drawspaces) using SGANNO and draw these 2 lines?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Solution: I answered my own question and  contacted tech support for them to create a defect entry, or at least generate a usage note describing this absurd behaviour.

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

I answered my own question.

I need to set Y1 and Y2 to missing before Y1C and Y2C are used.

Why oh why?

When space is datavalue  and the variable is character, why does SAS try to read Y1 and Y2 instead of Y1C and Y2C? And then throw a fit is that value is not missing?

 

Rick_SAS
SAS Super FREQ

In situations that involve switching drawing spaces, you might want to consider using the %SGANNO macros: SAS Help Center: SG Annotation Function Dictionary

The macros include a RESET="ALL" option, which clears values left over from other calls. For example, your program can be rewritten by using the %SGLINE macro, as follows:

%SGANNO
data T2;
%sgline(x1space='datavalue',
        x2space='datavalue',
        y1space='datapercent',
        y2space='datapercent',
        X1=13, X2=15, Y1=25, Y2=50); 
%sgline(drawspace='datavalue',
        X1=11, X2=13, YC1='Alice', YC2='Alice',
        reset="all"); 
run;

proc sgplot data=SASHELP.CLASS sganno=T2; 
  scatter x=AGE y=NAME;
run;
ChrisNZ
Tourmaline | Level 20

The %sganno macros present no interest to me. Among the reasons:

1. It's not easier to write

%sgtext( X1=50, Y1=50, LABEL='Player on court');

than

X1=50; Y1=50; LABEL='Player on court'; output;

2. You need to rewrite everything each time, you can't set a variable to use for several annotations like

X1=50;
%sgtext( Y1=50, LABEL='Player on court'); * DOES NOT WORK;
%sgtext( Y1=75, LABEL='Missed shots');

3. The macros break working code. If you try to mix %sganno and regular output, you quickly run into trouble.

data ANNO;
  FUNCTION='text'; X1=50; Y1=50; LABEL='On-court'; output;
  FUNCTION='line'; X1=25; X2=75; Y1=80;  Y2=Y1; output;
run;  

works but

data ANNO;
 %sgtext( X1=50, Y1=50, LABEL='On-court');
 FUNCTION='line'; X1=25; X2=75; Y1=80;  Y2=Y1; output;
run; 

generates

WARNING: The LINE function is missing required column. The function will be ignored.

which is NOT a helpful message.

The coded columns are exactly the same.

 

All in all, not worth the trouble. The plethora of variable names compared to %anno are painful enough, no need to add more pain.

 

ChrisNZ
Tourmaline | Level 20

Solution: I answered my own question and  contacted tech support for them to create a defect entry, or at least generate a usage note describing this absurd behaviour.

ChrisNZ
Tourmaline | Level 20

Fyi a defect has been raised. Hopefully his gets fixed.

I've reported this problem to development for fixing in a future release. Until that time, you'll need to use your circumvention of setting the Y1/Y2 values to missing.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 1147 views
  • 0 likes
  • 2 in conversation