Help using Base SAS procedures

ERROR: Libname LIBNAME is not assigned

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

ERROR: Libname LIBNAME is not assigned

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


Accepted Solutions
Solution
‎02-24-2016 01:43 PM
Community Manager
Posts: 2,757

Re: ERROR: Libname LIBNAME is not assigned

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;

View solution in original post


All Replies
Solution
‎02-24-2016 01:43 PM
Community Manager
Posts: 2,757

Re: ERROR: Libname LIBNAME is not assigned

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;
Occasional Contributor
Posts: 6

Re: ERROR: Libname LIBNAME is not assigned

That's amazing, thank you so much!
Occasional Contributor
Posts: 6

Re: ERROR: Libname LIBNAME is not assigned

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

Trusted Advisor
Posts: 1,115

Re: ERROR: Libname LIBNAME is not assigned

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.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 593 views
  • 1 like
  • 3 in conversation