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;
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

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;
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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-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!

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.

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
  • 4 replies
  • 13552 views
  • 2 likes
  • 3 in conversation