comp.soft-sys.sas - The SAS statistics package.
Hello, I'm using SAS' %LABEL annotate macro and I would like to set the color and font used for the label so that it is dependent on the variables F_ALLOWED and F_STUDY, respectively. I've been attempting to use code such as the following: data ANNOTATE; %dclanno; %system(2, 2); length FONT SYMBOL_COLOR $8; set FOR_ANNOTATE; if F_STUDY = 1 then FONT = "marker"; else FONT = "markere"; if F_ALLOWED = 0 then SYMBOL_COLOR = "red"; else SYMBOL_COLOR = "green"; %LABEL(SDAY_PDT, YVAL, "U", SYMBOL_COLOR, 0, 0, 1.25, FONT, +); run; Unfortunately, the %LABEL macro assumes that the &COLOR and &STYLE parameters are character literals and not variables. Accordingly, the annotate dataset contains values of "SYMBOL_C" for COLOR and "FONT" for STYLE, rather than the desired values. Now, I realize I could just code four %LABEL calls for each combination of F_STUDY and F_ALLOWED, but I would like to do something slicker with just one %LABEL call. Does anyone on the list have any suggestions? Many thanks, Matt Downs Statistics Collaborative, Inc. 1710 Rhode Island Ave NW Ste 200 Washington DC 20036
Hello, =20 I am using CALL EXECUTE in a DATA step to call a macro program which uses SQL pass-through to execute a SQL Server 2005 stored procedure. I need to pass two of the data set variables as macro parameters. The problem I am having is that the stored procedure has to have these parameters in SINGLE quotes. Initially, I used double quotes in the stored procedure syntax because I needed double quotes so the macro parameters would resolve - but I got a syntax error from SQL Server. =20 Now, I am trying to think of how I could add the single quotes to the data set variables, so they are passed as part of the macro parameter. Or, could I use a strategy to send the parameter without quotes and build a string that includes a single quote on each end of the resolved parameter (%sysfunc(cats("'",&vlab.,"'")) did not work). =20 I think I need a macro quoting expert! =20 This is what I have (which isn't working).. =20 * macro to create captions for SQL Server fields from SAS variable labels ; * (uses SQL pass-through facility) ; * vname - variable name ; * vlab - variable label ; %macro putlabs (vname=3D,vlab=3D); =20 proc sql; connect to odbc as mydb (datasrc=3D"wf_test_db"); execute (sys.sp_addextendedproperty @name=3DN'Caption' ,@value=3DN"&vlab."=20 ,@level0type=3DN'SCHEMA' ,@level0name=3DN'dbo' ,@level1type=3DN'TABLE' ,@level1name=3DN'pharm07_d' ,@level2type=3DN'COLUMN' ,@level2name=3DN"&vname." by mydb=20 ; quit; =20 %mend putlabs; =20 * create table of sas data set variables and labels ;=20 proc sql; =20 create table pharm07_labs as select name, label from dictionary.columns where libname =3D "WFD" and memname =3D "PHARM07_D" ; quit; =20 =20 * add captions to SQL Server fields ; data _null_; set pharm07_labs; call execute('%putlabs(vname=3D'||name||',vlab=3D'||label||')'); run; =20 =20 The CALL EXECUTE - as written - is properly sending the parameters, but the stored procedure is crashing because I am using double quotes around the macro variable names. =20 =20 Thanks in advance. =20 =20 Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County =20 =20
%Let Port=AB; %Macro Dummy(line); %Put &line; %Mend; How can I call the %Dummy macro (or modify it) so that it prints: "%Let MyPort=AB;" ? Calling it as %Dummy("%Let MyPort=&Port.;") doesn't work as %Let is evaluated before the call. Calling it as %Dummy(%Nrstr("%Let MyPort=&Port.;")) doesn't work as then &Port is not evaluated.
I am sending this again so that people know it is a new question...sorry about that! Kim Hi, I can't seem to figure this out. I am having a problem with the nk value, I think. I think that in the rand macro, it doesn't like my line %IF (UNIT <= b) %THEN TREAT = 1 The error message is: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &BLNUM ERROR: The %TO value of the %DO UNIT loop is invalid. ERROR: The macro RAND will stop executing. If anyone could help me it would be greatly appreciated; the code is below. Thanks! Kim %macro analysis(numSimulations=,K=, seed=,max_size=,mu=); %do ns = 1 %to &numSimulations; %do k = 1 %to &K; data _null_; nk=min(&max_size,ranpoi(&seed,&mu)); call symput("nk",left(put(nk,12.6))); stop; run; %rand(start=0,end=0,blnum=&nk,type=1); %end; %end; %mend; %macro rand(start=,end=,blnum=,type=); DATA A; %DO UNIT=1 %TO &blnum; b=&blnum/2; %IF (UNIT <= b) %THEN TREAT = 1; %ELSE TREAT = 2; OUTPUT; %END; run; %mend; %analysis(numSimulations=1,K=1, seed=0,max_size=30,mu=20);