BookmarkSubscribeRSS Feed
tomcmacdonald
Quartz | Level 8

Does it do anything? It seems to ignore it and treat my delimited file as a flat file.

7 REPLIES 7
Reeza
Super User

@tomcmacdonald wrote:

Does it do anything?

 

Yes. 

 


@tomcmacdonald wrote:

It seems to ignore it and treat my delimited file as a flat file.


You're using it incorrectly then. 

tomcmacdonald
Quartz | Level 8

Why does it bleed over into the other column?  Doesn't SAS know to stop when it hits the delimiter? 

Reeza
Super User

@tomcmacdonald wrote:

Doesn't SAS know to stop when it hits the delimiter? 


That's what it does. Like I said, you're likely doing something wrong. You need to show your code, log and ideally sample data that reflects your situation

tomcmacdonald
Quartz | Level 8

I just find the fact that it's bleeding over to be pretty bizarre.  You figure SAS would throw an error at least.

Kurt_Bremser
Super User

If SAS can do what you tell it to do, there's no reason to throw an error. And there are valid reasons for mixing list and formatted input (I guess that is the reason for your problem) at certain times.

ballardw
Super User

@tomcmacdonald wrote:

Why does it bleed over into the other column?  Doesn't SAS know to stop when it hits the delimiter? 


Show your log where you run the code Preferably in a code box opened with the forum's {I} icon. Also best would be to provide some example of the data file. Do not paste your data example into the main window but use a code box. The main message windows reformat pasted text.

 

there are potentially lots of interactions but the one I see here most frequently that sounds like what you describe is placing a format as part of the INPUT.

 

If you have

input var $10. it will read 10 characters pretty much.

 

informat var $10. ;

input var;

will read var as charcter up to the first delimiter if the infile is declared with the correct delimiter.

Other options such as DSD also have an impact.

ballardw
Super User

@tomcmacdonald wrote:

Why does it bleed over into the other column?  Doesn't SAS know to stop when it hits the delimiter? 


Please look at these code examples. Does your code look at all like the first one?

Note that the values of x and y vary between the two sets because the second is one preferred way to specify informats that respect delimiters;

data example;
   infile datalines dlm=',';
   length x $ 5;
   informat y z $5.;
   /* a format on an input statement ignores the 
    delimiter because you are forcing a read of 5 columns
   */
   input x $5.  y z;
datalines;
123,abcd,fghijk
;
run;
data example2;
   infile datalines dlm=',';
   length x y z $5.;
   input x  y z;
datalines;
123,abcd,fghijk
;
run;

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
  • 7 replies
  • 1930 views
  • 1 like
  • 4 in conversation