BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I am getting empty data set.

What is the way to solve it please?

 

data have;
input Z1 Z2 Z3 X1 X2 X3 X4 X5 X6 $ ;
cards;
2905817	1025710	314	40442 .	0 0.0346175427 1 C102
;
Run;
6 REPLIES 6
Kurt_Bremser
Super User

Maxim 3: Know Your Data, which also extends to "Know Your Datalines";

When I run your code with a little twist:

data have;
input;
put _infile_ $hex80.;
cards;
2905817	1025710	314	40442 .	0 0.0346175427 1 C102
;

I get this log:

 69         data have;
 70         input;
 71         put _infile_ $hex80.;
 72         cards;
 
 32393035383137093130323537313009333134093430343432202E093020302E3033343631373534

"37" is the hex code for the digit 7, and the immediately following hex code is "09", which means it's a tab.

But you also have blanks ("20") as delimiters; mixing delimiters is a BAD IDEA.

Replace all tabs with blanks, and it works:

data have;
input Z1 Z2 Z3 X1 X2 X3 X4 X5 X6 $ ;
cards;
2905817 1025710 314 40442 . 0 0.0346175427 1 C102
;

or make sure that all delimiters are tabs, so you can use

infile datalines dlm="09"x;

 

japelin
Rhodochrosite | Level 12

No ploblem.

Your code creates a dataset that has 1 obs.

japelin_0-1657181819816.png

 

Please check if there are any warnings or errors in the logs.

And restart SAS and then run this code by itself to see if it resolves the problem.

 

japelin
Rhodochrosite | Level 12

Exactly!😅

japelin_0-1657182332358.png

(this image is other text editor.)

Kurt_Bremser
Super User

Big hint: NEVER use tabs in code, unless you explicitly want them. And NEVER, NEVER, NEVER allow your editor to replace blanks with tabs.

For work purposes, my SAS editor is always set to replace tabs with blanks, on input and when code is loaded from a file. I only allow tabs in the On Demand session I use for the Communities, as I need to get code in there from postings of others "as is", so I can recreate the issues (as was the case here).

Kurt_Bremser
Super User

PS you can use a mix of delimiters, but I strongly recommend against it:

data have;
infile datalines dlm="0920"x;
input Z1 Z2 Z3 X1 X2 X3 X4 X5 X6 $ ;
cards;
2905817	1025710	314	40442 .	0 0.0346175427 1 C102
;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1216 views
  • 0 likes
  • 3 in conversation