Search code examples
sasdataset

In SAS, one variable cannot use the other when creating a dataset


I am creating a dataset where one variable is generated from a distribution using the other variable as an hyperparameter. However, it seems that I cannot do that. Is there anything wrong with my code?

%LET n=10; *sample size;
DATA d;
DO id = 1 TO &n;
 x = RAND('BERNoulli', 0.5);
 y = RAND('bernoulli', 1/(1+exp(-1+x)));
 output;
 END;
RUN;

proc print d;

My dataset looks like the following:

results

I cannot understand why variable y cannot use variable x. Any hints?


Solution

  • Did you not notice that the dataset d has two variables with seem to have the name x, but that one of these names in not left aligned?

    Remove the invisible unicode character 'e28083'x in front of x = and y = and your code will work.