Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Strings with double quotes having problem when used with DLM

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
raja Arumugam

New User


Joined: 30 Mar 2017
Posts: 5
Location: India

PostPosted: Thu Mar 30, 2017 10:34 am    Post subject: Strings with double quotes having problem when used with DLM
Reply with quote

Hi All,
I am new to SAS and my requirement is to read the input file, delimit by asterisk(*). But am facing problem with the output data when the input field holds double quotes in the string. Below is the sample code snippet used.
Input:
"SAMP-ALL" STORES

Code:
DATA TEST;
INFILE FILE;
INPUT @1 NAME $CHAR17.;
FILE OUTFIL DLM='*' DSD;
PUT NAME;

Output
"""SAMP-ALL"" STORES"

An Extra double quotes are getting added up in the output. Please note I want the output file in a dynamic way. Any help to fix this would be grateful.

[/u][/code]
Back to top
View user's profile Send private message

raja Arumugam

New User


Joined: 30 Mar 2017
Posts: 5
Location: India

PostPosted: Thu Mar 30, 2017 4:02 pm    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

Hi Prino,
Sorry am not getting your point. You mean to say string with double quotes will not work with DLM option and have to code in some other way?.
I want the output with double quotes as presented in input but extra double quotes are getting added up. I searched for manuals but could not locate any keyword which can eliminate extra quotes present in the output.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10272
Location: italy

PostPosted: Thu Mar 30, 2017 5:14 pm    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

SAS is NOT an IBM Tool,
topic moved
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8088
Location: East Dubuque, Illinois, USA

PostPosted: Fri Mar 31, 2017 1:21 am    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

I'm not sure your output makes sense based upon your code, but here's what SAS documentation says about DSD:
Quote:
DSD (delimiter sensitive data)

specifies that data values that contain embedded delimiters, such as tabs or commas, be enclosed in quotation marks. The DSD option enables you to write data values that contain embedded delimiters to LIST output. This option is ignored for other types of output (for example, formatted, column, and named). Any double quotation marks that are included in the data value are repeated. When a variable value contains the delimiter and DSD is used in the FILE statement, the variable value will be enclosed in double quotation marks when the output is generated. For example, the following code
DATA _NULL_;
FILE log dsd;
x='"lions, tigers, and bears"';
put x ' "Oh, my!"';
run;

will result in the following output:

"""lions, tigers, and bears""", "Oh, my!"
In other words, the output you posted is PRECISELY what you should have gotten based upon your code and your input. If this is not what you want, you'll need to either change your code or create the output record yourself and then write it without the DSD option or DLM option.

If you're new to SAS, you need to research the difference between the single quote mark (') and double quote mark (") -- they are treated very differently in SAS.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1497
Location: Chennai

PostPosted: Fri Mar 31, 2017 6:41 am    Post subject:
Reply with quote

Code:
Output
"""SAMP-ALL"" STORES"


What is the expected output?

You are doing DELIMITING by DLM, but still it delimits only variables. Now you have only one single variable and there is no need to delimit.

Quote:
Please note I want the output file in a dynamic way.

What is dynamic way?
Back to top
View user's profile Send private message
raja Arumugam

New User


Joined: 30 Mar 2017
Posts: 5
Location: India

PostPosted: Fri Mar 31, 2017 11:28 am    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

@vasanthz Thanks I just gave the issue field alone as an example for your easy reference. I do have ~200 fields to delimit. Below is the sample how i want the output.

Input
Code:
"SAMP-ALL" STORES31  YORK

Name : 1-17 (17 byte char)
Age : 18-19 (2 byte numeric)
City : 20-22 (3 byte Char) - Spaces are present
State: 23-26 (4 Byte char)

Actual Output:
Code:
"""SAMP-ALL"" STORES"*31**YORK


Expected Output
Code:
"SAMP-ALL" STORES*31**YORK


In the above output you should be able to see the difference in name field.(Dynamic way) If spaces are present in City field i just want the asterisk alone to represent the field and not the spaces like fixed fielded.

@Robert Thanks for your reply. All the fields are working fine in DLM DSD option except for the string with double quotes, hence wanted to check with you guys if anyone of you had faced this issue.
I tried using arrays it worked fine but to load the variables into array all the fields should be in same data type which takes more LOC to convert all the numeric variables to Char.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1497
Location: Chennai

PostPosted: Fri Mar 31, 2017 11:17 pm    Post subject:
Reply with quote

Based on your input and output, you need to remove the DSD option in your original code and you would get the output that you require.

From
Code:
FILE OUTFIL DLM='*' DSD;

to
Code:
FILE OUTFIL DLM='*';


Illustration:
Code:
DATA DOGE;                                               
INFILE cards;                                           
INPUT @1 NAME $CHAR17. @18 age 2. @21 City $char3.;     
FILE log DLM='*';                                       
PUT NAME age city;                                       
cards;                                                   
"SAMP-ALL" STORES31 YORK        <--- INPUT RECORD.                               
;                                                       
run;


OUTPUT:
Code:
"SAMP-ALL" STORES*31*YOR
Back to top
View user's profile Send private message
raja Arumugam

New User


Joined: 30 Mar 2017
Posts: 5
Location: India

PostPosted: Sat Apr 01, 2017 8:54 am    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

Vasanthz
I have tried this earlier.If you provide the exact input as given by me with spaces in the city field you will see the difference.
Output will be like
Name*age*space*state

Here I dont want the space to be populated only simple asterisk to denote the field. This cannot be achieved if I remove DSD, if DSD is there double quotes cannot be handled.
Back to top
View user's profile Send private message
CaptBill

New User


Joined: 28 May 2009
Posts: 20
Location: Oklahoma City, OK USA

PostPosted: Sat Apr 01, 2017 2:27 pm    Post subject: Re: Strings with double quotes having problem when used with DLM
Reply with quote

raja Arumugam wrote:
Hi All,
I am new to SAS and my requirement is to read the input file, delimit by asterisk(*). But am facing problem with the output data when the input field holds double quotes in the string. Below is the sample code snippet used.
[


I find that when I am facing a problem it helps if I make a 180 degree turn and then I am not facing it.


:-)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1804
Location: UK

PostPosted: Sat Apr 01, 2017 4:29 pm    Post subject:
Reply with quote

If you had botherted to use the code tags to present your code then the multiple spaces between STORES31 and YORK would have been clear and you would not have wasted Vasanthz's time. I have coded the relevant post.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 526
Location: The Universe

PostPosted: Sun Apr 02, 2017 6:26 am    Post subject:
Reply with quote

Just to be sure.

When you talk about double quote, do you mean a single character like (") or are you talking 2 single characters, like ('')? In z/OS something like '' is used to indicate a single ' in a context where a string in delimited by a ' character For example in JCL

PARM='DO YOU UNDERSTAND STEVE''S QUESTION?'

which creates DO YOU UNDERSTAND STEVE'S QUESTION?
Back to top
View user's profile Send private message
raja Arumugam

New User


Joined: 30 Mar 2017
Posts: 5
Location: India

PostPosted: Sun Apr 02, 2017 10:19 pm    Post subject: Reply to: Strings with double quotes having problem when used with DLM
Reply with quote

@Nic I tried copying the input snippet from mainframe but it didnt get pasted in forum.I didnt know how to use tag being first time user.I have given layout to showcase the space, sorry for the inconvenience.

@steve It is single character (").Given sample input and output as well.

Thanks everyone for your time.I got deadline until only tomorrow. If none of the option works I will remove DLM option and will go with array itself. Sorry guys if I did not explained clearly.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Translating Quotes Khadhar Basha CLIST & REXX 6 Tue May 09, 2017 11:52 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us