Hello,
Please I want to create factice variables but this error message is displayed, can someone help me ?
You likely have only READ access to the MYDATA folder.
Otherwise the code you wrote would replace the exercise1 data in that folder and anyone else using it would now have a different data set.
So as @PaigeMiller suggested, try writing it to the work library instead.
In general, never use this:
data mydata.exercice1; <- Input data set
set mydata.exercice1 ; <- output data set
If you make a mistake you ruin the original dataset and have to recreate it from scratch. For class work that's easy but you can't always recreate a data set.
@mateckma wrote:
Thanks for the repply, I'm using a virtual machine.
My code :
data mydata.exercice1;
set mydata.exercice1 ;
homme = 0;
if genre = 1 then homme = 1;
femme= 0;
if genre = 2 then femme = 1
homme = 0;
run;
proc freq data = mydata.exercice1;
tables genre*homme genre* femme;
run;
Error messages :
- User does not have appropriate authorization level for library
- Error: variable FEMME not found
Error: variable FOMME not found
Can you look at it again please?
data exercice1_ans;
set mydata.exercice1 ;
homme = 0;
if genre = 1 then homme = 1;
femme= 0;
if genre = 2 then femme = 1
homme = 0;
run;
proc freq data = exercice1_ans;
tables genre*homme genre* femme;
run;
What happens if you try this?
You don't have write access to library MYDATA.
Try this:
data exercicel;
set mydata.exercicel;
... the rest of your code goes here ...
In the future, please show us the whole log, as text (not as a screen capture). Copy the log as text and paste it into the window that appears when you click on the </> icon. Thanks.
Thanks for the repply, I'm using a virtual machine.
My code :
data mydata.exercice1;
set mydata.exercice1 ;
homme = 0;
if genre = 1 then homme = 1;
femme= 0;
if genre = 2 then femme = 1
homme = 0;
run;
proc freq data = mydata.exercice1;
tables genre*homme genre* femme;
run;
Error messages :
- User does not have appropriate authorization level for library
- Error: variable FEMME not found
Error: variable FOMME not found
Can you look at it again please?
Okay, I wanted to see the log, not the code. I wanted the log pasted into the window that appears when you click on the </> icon.
Do not split the log. Do not show us partial logs. Show us the entire log.
In this case, I already explained the first error. Since you have the first error, your variable FEMME and HOMME do not get created, and so these variable cannot be used until you fix the first error.
You likely have only READ access to the MYDATA folder.
Otherwise the code you wrote would replace the exercise1 data in that folder and anyone else using it would now have a different data set.
So as @PaigeMiller suggested, try writing it to the work library instead.
In general, never use this:
data mydata.exercice1; <- Input data set
set mydata.exercice1 ; <- output data set
If you make a mistake you ruin the original dataset and have to recreate it from scratch. For class work that's easy but you can't always recreate a data set.
@mateckma wrote:
Thanks for the repply, I'm using a virtual machine.
My code :
data mydata.exercice1;
set mydata.exercice1 ;
homme = 0;
if genre = 1 then homme = 1;
femme= 0;
if genre = 2 then femme = 1
homme = 0;
run;
proc freq data = mydata.exercice1;
tables genre*homme genre* femme;
run;
Error messages :
- User does not have appropriate authorization level for library
- Error: variable FEMME not found
Error: variable FOMME not found
Can you look at it again please?
data exercice1_ans;
set mydata.exercice1 ;
homme = 0;
if genre = 1 then homme = 1;
femme= 0;
if genre = 2 then femme = 1
homme = 0;
run;
proc freq data = exercice1_ans;
tables genre*homme genre* femme;
run;
What happens if you try this?
Thanks a lots, It runs now,
I use a virtual machine, when I copy the log to past out of the box (every where as a text), it doesn't work so, I must type all the log, I'm sorry for that.
You may have gotten your code to work. But I am pretty sure it does not do what is wanted. You should not have the final "homme=0" statement, because it means that the variable HOMME is always set to 0. And then the exercise of setting to 1 if GENRE=1 is wasted.
I can see that you are pretty new to SAS. You should learn to use the ELSE statement, I think you can get the correct output like this:
data exercice1;
set mydata.exercice1;
if genre=1 then homme=1;
else homme=0;
if genre=2 then femme=1;
else femme=0;
run;
Or, a bit more fast and dirty: a logical expression in SAS evaluates to 1 (true) or 0 (false). So this could also be written as
data exercice1;
set mydata.exercice1;
homme=genre=1;
femme=genre=2;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.