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

Hi everyone,

 

I am trying to show certain parameter estimates in a caterpillar graph.

I am conducting a Bayesian analysis with proc bchoice and get many different estimates per individual (I have 1,000 survey participants).

So e.g. I have a variable that is named AA,N 0001 which is the estimate for AA for individual 0001.

I am trying to put all estimates in a caterpillar graph but it wouldn't work.

 

I have tired %cater(datat=mydata, var=AA,N_: ) ; but I get: All positional parameters must percede keyword parameters.

If I try %cater(datat=mydata, var=AA: ) ; but I get: Syntax error.

 

Thanks for your help!

 

Best,
Alex

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
How are these variable names being created? By what procedure?

Just curious what will happen if you issue:
options validvarname=v7;

and see whether your variable names get changed to something like AA_N_001 and AA_N_002, etc. Or whether you get error messages.

It would be very unusual for a SAS procedure to make a variable name with a comma and a blank in the name. You might want to open a ticket with Tech Support.

Under normal circumstances, I would expect some kind of error like this:
ERROR: The value AA,N 001 is not a valid SAS name.

but it would have to happen in the step some place before your macro call.

The bottom line is that you can't have a comma in the variable name and I'm not sure that quoting functions or using a named literal will help you here because I am not sure using a named literal like 'AA,N 001'n will work in the Macro program. That would be a question for Tech Support.

cynthia

View solution in original post

11 REPLIES 11
Cynthia_sas
SAS Super FREQ
Hi:
Did you test out the example in the DOC? When I tried the example shown here:
http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_mcmc_details...
for the %CATER macro all the statements ran for me without any macro errors such as you report.

In the documentation example, the PROC MCMC step creates DELTA_1 thru DELTA_21 variables, so the macro parameter in the doc shows:
%CATER(data=postout, var=delta:), which to me indicates that the macro program was designed to take one value, not values separated with commas. But a variable name of "AA,N 001" is not a valid variable name. SAS variable names cannot contain commas or spaces.

Have you run a PROC CONTENTS on your data to see what the variable names are -- it seems like you might be using labels instead of variable names.

cynthia
ahoeweler
Calcite | Level 5

Hi Cynthia,

 

thank your for your quick answer. I just ran proc contents and it shows me the variable names (e.g. AA,N 0001, AA,N 0002, etc.), the type (numerical) and the length (8).

Do you think I have to rename the variables?

 

Thank you!

Alex

Cynthia_sas
SAS Super FREQ
Hi:
How are these variable names being created? By what procedure?

Just curious what will happen if you issue:
options validvarname=v7;

and see whether your variable names get changed to something like AA_N_001 and AA_N_002, etc. Or whether you get error messages.

It would be very unusual for a SAS procedure to make a variable name with a comma and a blank in the name. You might want to open a ticket with Tech Support.

Under normal circumstances, I would expect some kind of error like this:
ERROR: The value AA,N 001 is not a valid SAS name.

but it would have to happen in the step some place before your macro call.

The bottom line is that you can't have a comma in the variable name and I'm not sure that quoting functions or using a named literal will help you here because I am not sure using a named literal like 'AA,N 001'n will work in the Macro program. That would be a question for Tech Support.

cynthia
ahoeweler
Calcite | Level 5

Hi Cynthia,

 

the variables are produced by the BCHOICE procedure. I am using the "random" option in order to create a random effects model.

The variables are produced in the output data set.

 

Best,

Alex

Rick_SAS
SAS Super FREQ

I think you are seeing labels, not variable names. Run the following to see the real names:

 

proc contents data=MY_OUTPUT_DATA short;

run;

 

You ought to be able to cut and paste from that output into the macro.

 

I ran the Getting Started example, which uses a RANDOM statement. I used the OUTPOST= option on the PROC BCHOICE statement to create an output data set.  In that example, the variable names are created as normal SAS variables, but the labels are as you described.

ahoeweler
Calcite | Level 5

Hi,

 

I did run proc contents and it shows me the Variables (AA,N 0001), its type, the length and the label (AA,N 0001). So the label and the variable name seem to be identical in this case. How can this be?

Rick_SAS
SAS Super FREQ

Please provide

1. the PROC BCHOICE code that you are using

2. The output from

    proc contents data=MY_OUTPUT_DATA    SHORT;

    run;

    where you replace MY_OUTPUT_DATA by the name of the data set created by PROC BCHOICE.

ahoeweler
Calcite | Level 5

proc bchoice    data=CSDesignEffect outpost=EffectPost
                nmc=5000 thin=2 seed=123
                nthreads=4 ;
class N Set;

model choice=     No
                AA AF BA DL _50_ _100_
                P1100 P1300 P1800 P2000
                /    choiceset=(Set);

                random AA _50_  P1100
                / subject=N
                monitor=(1 to 5) type=un;
run;


Pro Contents.png
Rick_SAS
SAS Super FREQ

You dd not use the SHORT option:

 

proc contents data=EffectPost  SHORT;

run;

Rick_SAS
SAS Super FREQ

Please also submit

 

proc options option=validvarname value;
run;

 

and copy/paste the output that appears in the SAS log.  It will look something like this:

 

Option Value Information For SAS Option VALIDVARNAME
Value: V7
Scope: Default
How option value set: Shipped Default

ahoeweler
Calcite | Level 5

Hi,

 

the validvarname=v7 code worked, thank you very much Rick and Cynthia!

 

Best,
Alex

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 1587 views
  • 0 likes
  • 3 in conversation