Help using Base SAS procedures

PROC FORMAT for negative range in UNIX (bash)

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

PROC FORMAT for negative range in UNIX (bash)

Hello Everyone, I'm trying to execute below code in UNIX (bash):

proc format;

value attr4_fmt
        low - < -90000 = "(< -90000)"
       -90000 - 523999 = "(-90000 - 523999)"
        524000 - high = "(523999 <)";
run;

 

But getting following error:

 

NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

1531    +        -90000 – 523999 = "(-90000 – 523999)"
                            _
                           22
                           76
ERROR 22-322: Syntax error, expecting one of the following: (, ',', -, <, =.

ERROR 76-322: Syntax error, statement will be ignored.

 

Can someone please help to figure out what I'm missing here ?


Accepted Solutions
Solution
‎04-18-2016 11:21 AM
Trusted Advisor
Posts: 1,115

Re: PROC FORMAT for negative range in UNIX (bash)

[ Edited ]

I'd say, simply overtype this "mock hyphen" with an ordinary hyphen or copy and paste one of the minus signs from your code at this place.

 

Edit: Also, with this character I get the same error message in a Windows SAS session -- not surprisingly, because SAS requires the correct characters, regardless of the operating system.

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: PROC FORMAT for negative range in UNIX (bash)

Works fine on 9.4 windows SAS (note you dont need the < in the first one, it is low to -9000).  Have you tried resetting and running just that code, am thinking maybe something else is causing the problem.:

proc format;
  value attr4_fmt
    low - -90000 = "(< -90000)"
    -90000 - 523999 = "(-90000 - 523999)"
    524000 - high = "(523999 <)";
run;
Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

[ Edited ]

Yes, that's correct it works completely fine in Windows environment, but in UNIX it doesn't, I believe it's because of misinterpretation of -(negative) sign with -(dash) sign of range by UNIX. I tried running this code after removing negative sign and it worked.

Trusted Advisor
Posts: 1,115

Re: PROC FORMAT for negative range in UNIX (bash)

Sounds strange. Can you perhaps save your code (only the PROC FORMAT step) and post it as an attachment (.txt file)?

Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

Attached is the code I'm using in .txt file.

Trusted Advisor
Posts: 1,115

Re: PROC FORMAT for negative range in UNIX (bash)

I've just looked at your first attachment with a hex editor: As expected, the "hyphen" in question (between -90000 and 523999) is different from the others: It is '96'x, not '2D'x as it should.

Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

Can you please explain this a bit, I'm very new to UNIX so don't have much idea about it.
Solution
‎04-18-2016 11:21 AM
Trusted Advisor
Posts: 1,115

Re: PROC FORMAT for negative range in UNIX (bash)

[ Edited ]

I'd say, simply overtype this "mock hyphen" with an ordinary hyphen or copy and paste one of the minus signs from your code at this place.

 

Edit: Also, with this character I get the same error message in a Windows SAS session -- not surprisingly, because SAS requires the correct characters, regardless of the operating system.

Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

Many Thanks Smiley Happy
Super User
Posts: 5,082

Re: PROC FORMAT for negative range in UNIX (bash)

I copied the code as posted, and it ran fine under Unix.  Perhaps there are slight differences between your Windows code and your Unix code?  You could find out by reading your code (line by line, as a long character variable), and printing it out in hex.

Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

I'm using attached code in UNIX, can you please have a look and suggest if I'm missing something ?

Trusted Advisor
Posts: 1,115

Re: PROC FORMAT for negative range in UNIX (bash)

Hello @KP12,

 

While your code seems to be okay (and I think you do need the "<" sign), your log excerpt shows different types of "hyphens." Please replace all these by ordinary hyphens and the errors should go away.

Contributor
Posts: 24

Re: PROC FORMAT for negative range in UNIX (bash)

Hello @FreelanceReinhard,

Actually I copied the log and pasted here so it looks like different types of hyphens (may be because of font change while pasting), in real all are ordinary hyphens only.
Respected Advisor
Posts: 3,777

Re: PROC FORMAT for negative range in UNIX (bash)

It's not the negative 9000 is it the hyphen between the values.  It is hex '96'x not '2D'x like it should be.

 

Capture.PNG

☑ This topic is SOLVED.

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

Discussion stats
  • 13 replies
  • 745 views
  • 1 like
  • 5 in conversation