DATA Step, Macro, Functions and more

no observations copied

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

no observations copied

 

Hpw do I do this??

Please someone help me

 

Table A1 : Conisit of 10 columns and there are 100 records
create a TABLE B1 from A1 where B1 should contain only the structure of A1 and no records should be copied.

 

Thank you


Accepted Solutions
Solution
‎12-16-2016 06:28 AM
Trusted Advisor
Posts: 1,586

Re: no observations copied

and one more:

 

data b1; set a1(obs=0); run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,997

Re: no observations copied

Well, Q1 - why, not really much point creating an emtpy copy of a dataset.  But anyways, two options:

proc sql;
  create table WANT as
  select *
  from   HAVE
  where 1=0;
quit;

data want;
  set have;
  if _n_ < 0 then output;
run;

You could also generate it from metadata, but thats probably more code than the above.  

Super User
Posts: 19,877

Re: no observations copied

Proc SQL;

create table b1

 like a1;

quit;

Super User
Super User
Posts: 7,997

Re: no observations copied

Nice, I always forget the like command.

Solution
‎12-16-2016 06:28 AM
Trusted Advisor
Posts: 1,586

Re: no observations copied

and one more:

 

data b1; set a1(obs=0); run;

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 264 views
  • 3 likes
  • 4 in conversation