BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5

data l i am having a record in a table  that data in that record is having with tab Ex: OBS_Data done this ok Now i want to split it in to obs Obs1  -Done Obs2- this obs3-ok or is there any way in the data that we can replace tab with | or ^ Ex:  done^this^ok

4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12

Your question isn't very clear to me.  If you have a string and want to replace the tab character with a | or ^, then you can just use the TRANSWRD function.

out = transwrd(in,'09'x,"|");

'09'x is the hex code for a tab in ASCII.  If it is an EBCDIC code, you'll need to look it up.

Doc Muhlbaier

Duke

R_Win
Calcite | Level 5

done this ok i have tryed on this data for example it shd be Input: done this ok output shd be done|this|ok you can che the text file

mkeintz
PROC Star

You probably want the double trailing @@, which allow you to easily read multiple observations from a single input data line.  I believe the tabs will just be treated as white space (so SAS will see each tab-deliminted value as a single variable), so you don't need any DLM stuff unless you have contiguous tabs:

data want;

  infile datalines

  input text : $10. @@;

datalines;

done     this     ok

run;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Tom
Super User Tom
Super User

TABS are not treated the sames as spaces unless you tell it differently on the INFILE statement.

You could use DLM='2009'x to treate space and tab as delimiters

Or use EXPANDTABS to have it convert the tabs to spaces on the way into the input buffer.

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!

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
  • 4 replies
  • 2839 views
  • 0 likes
  • 4 in conversation