Help using Base SAS procedures

Format procedure

Reply
Occasional Contributor
Posts: 6

Format procedure

[ Edited ]

Hi All,

 

I am trying to debug a code developed by someone else and have got stuck on the following section of code:

 

data mydata.finalpermin;
set nwsleep;
drop asleepnw addnwid nwinsleep;
format finalnw yesno. finalsleep yesno. sleepnwidentifier yesno.;
label finalnw = "Identifier for minute of non-wear (yes/no)" finalsleep = "Identifier for
minute of sleep (yes/no)"
sleepnwidentifier = "Identifier for minute of sleep OR non-wear (yes/no)"
Steps = "Total steps for the minute processed with Low Frequency Extension OFF" Paxn =
"Sequential Minute"
Paxinten = "Total intensity counts in the vertical axis for the minute"
Axis2 = "Total intensity counts in the anterior-posterior axis for the minute"
Axis3 = "Total intensity counts in the medial-lateral axis for the minute"
slpperiod = "Sequential sleep period" wkperiod = "Sequential wake period";
run;

 

It comes up with the following error:

ERROR 48-59: The format YESNO was not found or could not be loaded.

 

I have tried putting in a Proc format as follows but it still comes up with the error above:

 

Proc format;
value $ yesno.
"0" = "no"
"1" = "yes"
;

 

Can anyone help me please?

 

Many thanks,

 

Mel

Super User
Super User
Posts: 7,988

Re: Format procedure

Posted in reply to Mel120585

The format in question: YESNO.

Is a numeric format not a character format, so change your proc format to be:

Proc format;
  value yesno
    0 = "no"
    1 = "yes";

run;

Occasional Contributor
Posts: 6

Re: Format procedure

Thank you very much. It seems to have worked but has thrown up another error now from the following code:

 

proc sort data=bed1 nodupkey dupout=mult out=newbed;
by pid noon;
run;

 

It gives: 

 

Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA,
DATECOPY, DETAILS, DIAG, EBCDIC, EQUALS, FINNISH, FORCE, IN, ISA, L, LEAVE, LIST,
MESSAGE, MSG, NATIONAL, NODUP, NODUPKEY, NODUPKEYS, NODUPLICATE, NODUPLICATES,
NODUPREC, NODUPRECS, NODUPS, NOEQUALS, NORWEGIAN, NOTHREADS, OSA, OUT, PAGESIZE,
PSIZE, REVERSE, SIZE, SORTSEQ, SORTSIZE, SORTWKNO, SWEDISH, T, TAGSORT, TECH,
TECHNIQUE, TESTHSI, THREADS, WKNO, WORKNO.
ERROR 76-322: Syntax error, statement will be ignored.

 

I have checked online but it seems that this statement is written correctly. Could you give any suggestions as to what I am missing please?

 

Sorry to ask another question.

 

Thanks

 

Mel

Super User
Super User
Posts: 7,988

Re: Format procedure

Posted in reply to Mel120585

Well, I can't see a problem with that code directly (and can't test now as not at work), but can you post the log, the step prior to this sort, and all the ways up to the end of the error - exactly the log.  Am wondering if something before the sort is causing a problem.  you could also try changing the position of the proc's parameters, e.g move out= before the nodupkey.

Super User
Posts: 5,516

Re: Format procedure

Posted in reply to Mel120585

The code you posted looks correct, but the error indicates that you probably left off the semicolon at the end of the PROC SORT statement.

Occasional Contributor
Posts: 6

Re: Format procedure

Posted in reply to Astounding

I have tried putting a semincolon in and that didn't help and I have tried moving the order around and the same error keeps coming up. Below is the code above and below where the error is occuring:

 

proc sort data= mydata.finalpermin;
by pid slpperiod paxn ;
run;
data bed1;
set mydata.finalpermin;
where finalsleep = 1 and noon ge 1 and noon < 7;
run;
proc sort data=bed1 nodupkey dupout=mult out=newbed;
by pid noon;
run;
data bed2;
set newbed;
bedtime = acceltime;
format bedtime time8.2;
keep pid noon bedtime;
run;
proc sort data = bed1;
by pid slpperiod descending paxn;
run;

Any help appreciated!

 

Thanks

 

Mel

Super User
Posts: 7,854

Re: Format procedure

Posted in reply to Mel120585

The log would be more helpful, as the position of the ERROR message is a good guide on the way to finding the offending location in the code.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,044

Re: Format procedure

Posted in reply to Mel120585

Try add a system option .

 

options nofmterr;
Ask a Question
Discussion stats
  • 7 replies
  • 459 views
  • 0 likes
  • 5 in conversation