DATA Step, Macro, Functions and more

GETOPTIONS Question

Reply
Trusted Advisor
Posts: 1,615

GETOPTIONS Question

I have a long list of colors, set in GOPTIONS

goptions colors=(black red green blue cyan magenta orange lightblue limegreen purple brown yellow salmon

    darkgreen pink turquoise tan olive firebrick slateblue orangered yellowgreen teal gray44 blueviolet

    crimson chocolate darkmagenta gold silver peru plum powderblue tomato olivedrab lavender khaki darkgray

    cornsilk deepskyblue deeppink goldenrod);

Then I try to obtain this same list of colors in a macro variable for use in the program:

%let colors=%sysfunc(getoption(colors));

and the resulting macro variable is

( BLACK RED GREEN BLUE CYAN MAGENTA ORANGE LIGHTBLU LIMEGREE PURPLE BROWN YELLOW SALMON DARKGREE PINK TURQUOIS TAN OLIVE

FIREBRIC SLATEBLU ORANGERE YELLOWGR TEAL GRAY44 BLUEVIOL CRIMSON CHOCOLAT DARKMAGE GOLD SILVER PERU PLUM POWDERBL TOMATO

OLIVEDRA LAVEN

I understand why the color names are maximum eight  characters, that's fine, not a problem. I do not understand why the macro variable ends with laven (lavender) and doesn't include the remaining colors.

What is the problem here? How do I fix this?

Super User
Super User
Posts: 7,401

Re: GETOPTIONS Question

I would say you've hit a maximum length for macro variables there $2000.  Have a look in SASHELP.VGOPT dataset, you can find COLORS option there, I would expect more than one, try processing from that rather than assign to macro var.

Occasional Contributor
Posts: 7

Re: GETOPTIONS Question

The maximum number of characters which can be stored in a macro variable is 32767, not 2000. The limit must be down to the getoption() function.

Trusted Advisor
Posts: 1,615

Re: GETOPTIONS Question

Maybe it is a limit with GETOPTION, seems like the limit might be 256 characters

Nevertheless, I can get the information out of the SASHELP.VGOPT table

Super User
Posts: 5,082

Re: GETOPTIONS Question

A related limit ... but not the one you are running into ... within SASHELP.VGOPT, the variable SETTING which holds the colors list is limited to 1024 characters. 

Respected Advisor
Posts: 3,777

Re: GETOPTIONS Question

VGOPT SETTINGS contains something even more bizarre when I ran it.

( BLACK  RED  GREEN  BLUE  CYAN  MAGENTA  ORANGE  LIGHTBLU E LIMEGREE N PURPLE  BROWN  YELLOW  SALMON  DARKGREE N PINK  TURQUOIS E TAN  OLIVE  FIREBRIC K SLATEBLU E ORANGERE D )

Trusted Advisor
Posts: 1,615

Re: GETOPTIONS Question

I'm not seeing that particular issue, data_null_;

Respected Advisor
Posts: 3,777

Re: GETOPTIONS Question

I can only see the "correct" (truncated to 8 byte words) list with PROC GOPTIONS.

19         proc goptions option=colors;
20            run;

                                            
SAS/GRAPH software options and parameters
                                            (executing in IOM ROOT COMP ENV environment)

COLORS=( BLACK RED GREEN BLUE CYAN MAGENTA ORANGE LIGHTBLU LIMEGREE PURPLE BROWN YELLOW SALMON DARKGREE PINK TURQUOIS TAN OLIVE
FIREBRIC SLATEBLU ORANGERE YELLOWGR TEAL GRAY44 BLUEVIOL CRIMSON CHOCOLAT DARKMAGE GOLD SILVER PERU PLUM POWDERBL TOMATO OLIVEDRA
LAVENDER KHAKI DARKGRAY CORNSILK DEEPSKYB DEEPPINK GOLDENRO )
                             Default color list
Super Contributor
Posts: 273

Re: GETOPTIONS Question

Yes i see too it like so

aw2014-03-11_154921.png

searching color name i have found that in the register you have colors in short for the html colors

but only for G O P    green orange and purpleaw2014-03-11_154851.png

!!!!!!

Trusted Advisor
Posts: 1,615

Re: GETOPTIONS Question

Andre and data_null_; what version of SAS, what operating system? I am not seeing this with SAS 9.4, Windows 7 PRO 64bit

Respected Advisor
Posts: 3,777

Re: GETOPTIONS Question

I am running 9.3 (TS1M2) on SunOS 5.10 (SUN 64).

Trusted Advisor
Posts: 1,615

Re: GETOPTIONS Question

Paige is wondering if you should report this as a bug, and see what SAS has to say ... it sure seems like a bug to me ... of course, if this is not something you would ever need in your work then you may not want to bother

Super Contributor
Posts: 273

Re: GETOPTIONS Question

Paige

My version is sas 9.3.2 Windows 7 32 bits

Andre

Respected Advisor
Posts: 3,124

Re: GETOPTIONS Question

FYI, at least since SAS 9.2, the max length of a macro variable was bumped up to 65,534

Haikuo

Super User
Super User
Posts: 6,500

Re: GETOPTIONS Question

You seem to have hit the limit on the COLORS option.  What use do you have for so many colors? I doubt that any graph produced with so many colors would be readable by humans.

Ask a Question
Discussion stats
  • 18 replies
  • 518 views
  • 3 likes
  • 8 in conversation