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

Hi,

 

I am new to SAS and have managed to download SAS 9.0 to try and run a code I have been provided to analyse some data. However, it is getting stuck at the following point:

 

data libname.pampermin;
set sets;
ProbSleep = 7.601 - (0.065*MeanW5) - (1.08*sumind) - (0.056*STDpre5) -
(0.703*logact);
if probsleep = . THEN DO; PROBSLEEP = 1; END;
if probsleep < 0 and probsleep ne . then SleepIncOff = 0; if (probsleep ge 0) or
inclinometer = 0 then SleepIncOff = 1;
drop lastpax time;
run;

 

When it gets to this section, it comes up with "ERROR: Libname LIBNAME is not assigned." This is the first time in the code that Libname is referred to. I have tried to read other threads on this to do with assigning a pathway but can't make any progress. Could anyone give me some suggestions as to how I resolve this issue please?

Many thanks,

 

Mel

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

You need to have a statement that maps the LIBNAME to the path where your data resides.

 

Ex:

 

libname libname "C:\projects\mydata";

 

BTW, I suggest you don't use libname as the name of the library - will confuse you more.

 

libname mydata "C:\projects\mydata";

data mydata.pampermin;
set sets;  /* this is going to be in your WORK library.  Does the data exist? */
ProbSleep = 7.601 - (0.065*MeanW5) - (1.08*sumind) - (0.056*STDpre5) -
(0.703*logact);
if probsleep = . THEN DO; PROBSLEEP = 1; END;
if probsleep < 0 and probsleep ne . then SleepIncOff = 0; if (probsleep ge 0) or
inclinometer = 0 then SleepIncOff = 1;
drop lastpax time;
run;
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

View solution in original post

4 REPLIES 4
ChrisHemedinger
Community Manager

You need to have a statement that maps the LIBNAME to the path where your data resides.

 

Ex:

 

libname libname "C:\projects\mydata";

 

BTW, I suggest you don't use libname as the name of the library - will confuse you more.

 

libname mydata "C:\projects\mydata";

data mydata.pampermin;
set sets;  /* this is going to be in your WORK library.  Does the data exist? */
ProbSleep = 7.601 - (0.065*MeanW5) - (1.08*sumind) - (0.056*STDpre5) -
(0.703*logact);
if probsleep = . THEN DO; PROBSLEEP = 1; END;
if probsleep < 0 and probsleep ne . then SleepIncOff = 0; if (probsleep ge 0) or
inclinometer = 0 then SleepIncOff = 1;
drop lastpax time;
run;
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
Mel120585
Fluorite | Level 6
That's amazing, thank you so much!
Mel120585
Fluorite | Level 6

I'm sorry to ask yet another question but it is now saying that there is a syntax error in the following:

 

if wake1 < bed1 then; SleepNWmins = ((wake1 + ('24:00:00't bed1))+'00:01:00't)/60;

 

I am trying to find the missing syntax but is it obvious to everyone else?!

 

Thanks again,

 

Mel

FreelanceReinh
Jade | Level 19

Hi @Mel120585,

 

No problem. This forum is a great place for asking questions. Best practice is to open a new thread for a new question.

 

I think, there are two errors in your code:

  1. The syntax error that there is no operator between '24:00:00't and bed1. I guess a minus sign could make sense here (if I interpret the formula correctly).
  2. A logical error: I guess (again) that you want to execute the assignment statement SleepNWmins = ... if the condition wake1 < bed1 is met. Due to the semicolon after then, however, you instructed SAS to do nothing if the condition is met and then execute the assignment statement regardless whether the condition is met (it appears as a completely separate statement). So, almost certainly you will want to delete that semicolon in the middle.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 14701 views
  • 2 likes
  • 3 in conversation