DATA Step, Macro, Functions and more

record are all missing

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

record are all missing

[ Edited ]
 

Accepted Solutions
Solution
‎08-27-2016 12:18 AM
Respected Advisor
Posts: 4,927

Re: how to add a record into an empty dataset. And the values in this record are all missing

Get the variable names, but don't read the dataset as that will stop the data step before you can add a new record:

 

/* Create an empty dataset */
data a;
length x y 8 r s t $12;
stop;
run;

/* Add a new record */
data b;
if 0 then set a; /* Get the var names, but don't read */
output;
stop;
run;
PG

View solution in original post


All Replies
Super User
Posts: 19,822

Re: how to add a record into an empty dataset. And the values in this record are all missing

Do you already have the empty dataset?

 

untested but I would try something like the following:

 

data want;

set want;

call missing(_all_);

output;

run;

 

 

Solution
‎08-27-2016 12:18 AM
Respected Advisor
Posts: 4,927

Re: how to add a record into an empty dataset. And the values in this record are all missing

Get the variable names, but don't read the dataset as that will stop the data step before you can add a new record:

 

/* Create an empty dataset */
data a;
length x y 8 r s t $12;
stop;
run;

/* Add a new record */
data b;
if 0 then set a; /* Get the var names, but don't read */
output;
stop;
run;
PG
Valued Guide
Posts: 505

Re: how to add a record into an empty dataset. And the values in this record are all missing

see ( if you need to preserve dataset label)
http://goo.gl/FvNbjT

Simplest?

proc sql;
  create table class like sashelp.class
;quit;

* unfortunately the dataset label is not preserved;

Valued Guide
Posts: 505

Re: how to add a record into an empty dataset. And the values in this record are all missing

Posted in reply to rogerjdeangelis

Ignore my previous post, I missunderstood the problem. My solution does not have one observation with missing values.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 298 views
  • 1 like
  • 4 in conversation