BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shynu
Fluorite | Level 6

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

and one more:

 

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

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

Reeza
Super User

Proc SQL;

create table b1

 like a1;

quit;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Nice, I always forget the like command.

Shmuel
Garnet | Level 18

and one more:

 

data b1; set a1(obs=0); 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
  • 4 replies
  • 1001 views
  • 3 likes
  • 4 in conversation