BookmarkSubscribeRSS Feed
rohitkrishna
Calcite | Level 5

Hi all,

i'm not able to print a single quote for one of my variables I tried with different types like  catt, quote(id,"'") but it gives the double quote's only so please suggest some solution for the problem

 

{

DATA _LIC;
INFILE DATALINES;
INPUT @1 ID 1. @3 LIC $10.;
DATALINES;
1 24356578
2 42437254
3 36353239
4 25242762
5 26525326
;
RUN;
DATA _LIC2;
SET _LIC;
ID_NEQ = QUOTE("'",LIC,"'");
RUN;
PROC PRINT DATA = _LIC2;
RUN;    

}

 

expecting results should be like : ('24356578') not like ("24356578")

 

Thanks & reagrds 

rohit

 

11 REPLIES 11
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

In this case, the documentation for the Quote Function.

Excerpt:

argument-2

specifies a quoting character, which is a single or double quotation mark. Other characters are ignored and the double quotation mark is used. The double quotation mark is the default.

 

Note that the quote() function will only accept TWO arguments. The ERROR in your log (Maxim 2!) tells you that.

So this gives you your result:

data test;
x1 = 'string';
x2 = quote(x1,"'");
run;

proc print data=test noobs;
run;

Result:

  x1         x2

string    'string'
gamotte
Rhodochrosite | Level 12

Hello,

 

If you read the log, you will see that your program produces an error :

 

10   ;
11   RUN;
12   DATA _LIC2;
13   SET _LIC;
14   ID_NEQ = QUOTE("'",LIC,"'");
              -----
              72
ERROR 72-185: The QUOTE function call has too many arguments.

15   RUN;

 

Indeed, according to the documentatiopn, the quote function has two arguments :

 

Required Arguments

argument-1

specifies a character constant, variable, or expression.

argument-2

specifies a quoting character, which is a single or double quotation mark. Other characters are ignored and the double quotation mark is used. The double quotation mark is the default.

 

=> Replace your call to quote function with

ID_NEQ = QUOTE(LIC,"'");
rohitkrishna
Calcite | Level 5
Hi KurtBremser,
thanks for the quick replay & below the details of the above code results
{
DATA _LIC;
X = 'STRING';
Y = QUOTE(X,"'");
RUN;
PROC PRINT DATA = _LIC;
RUN; }

and the results are
Obs X Y

1 STRING "STRING"

again I am getting double quotes only

thanks & regards
rohit
Kurt_Bremser
Super User

This is strange, and I fear you have a "mainframe problem".

Your code, run on SAS 9.4 on AIX, creates single quotes.

 

Since there is no mention in the documentation of special behavior of this function on mainframes, I would bring this to the attention of SAS technical support.

I also did not find anything regarding the quote() function in the Companion for Z/OS.

andreas_lds
Jade | Level 19

No problem with SAS 9.4m5 on Windoze.

 

EDIT: Which version are you using?

rohitkrishna
Calcite | Level 5
Hi andreas_lds,
thanks for the quick replay
the current version i'm using 8.1

thanks & regards
rohit
Kurt_Bremser
Super User

@rohitkrishna wrote:
Hi andreas_lds,
thanks for the quick replay
the current version i'm using 8.1

thanks & regards
rohit

So you're calling from 2003 or so via time-machine?

 

8.1 is the subject of IT archaeologists, as it was introduced in 2001 and must have been taken off support in 2008 (IIRC) when 9.2 was introduced.

 

I'm astonished that SAS still hands out licenses for this.

 

Have your SAS admins upgrade to the current versions 10 years before yesterday. What they've been doing can be considered as gross negligence.

 

Once you're current, we can test again, and if the issue persists, involve SAS TS right then. But with 8.1, they only thing you'll hear from them is "upgrade to the current version".

rohitkrishna
Calcite | Level 5
Hi KurtBremser,
thanks for the replay
ya this has the oldest project we are working
so what is the solution for the above issue
thanks & regards
rohit
ballardw
Super User

@rohitkrishna wrote:
Hi KurtBremser,
thanks for the quick replay & below the details of the above code results
{
DATA _LIC;
X = 'STRING';
Y = QUOTE(X,"'");
RUN;
PROC PRINT DATA = _LIC;
RUN; }

and the results are
Obs X Y

1 STRING "STRING"

again I am getting double quotes only

thanks & regards
rohit

Why does your code have { } around the SAS code?

On a windows machine the result is also:

Obs      X          Y

 1     STRING    'STRING'
Tom
Super User Tom
Super User

If you are really running a version of SAS that was released almost 20 years ago then use functions that work in that version.

DATA _LIC;
  INFILE DATALINES;
  INPUT @1 ID 1. @3 LIC $10.;
DATALINES;
1 24356578
2 42437254
3 36353239
4 25242762
5 26525326
;
RUN;
DATA _LIC2;
  SET _LIC;
  length ID_NEQ $12;
  ID_NEQ = "'" || trim(LIC) || "'";
RUN;
rohitkrishna
Calcite | Level 5
Hi Tom,
thanks for the quick replay
it superb it's working
thanks & regards
rohit

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 11 replies
  • 1509 views
  • 2 likes
  • 6 in conversation