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;
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;
No ploblem.
Your code creates a dataset that has 1 obs.
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.
You probably have your editor set to replace all tabs with blanks, so it auto-corrects the mistake of the OP 😉
Exactly!😅
(this image is other text editor.)
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).
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
;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.