f



Re: Creating an empty SAS data set #5

I don't think your solution addresses the second part of the original
question, only the first part.

There are at least two other ways in SQL to do what your code does:

   create table new as select * from old (obs=0);

   create table new like old;

In general, though, if you want to create one table that's exactly like
another data set, you would need to use PROC COPY, which can also create
the indexes and constraints in the original data set.

Without knowing how to tell which variables are "black" and which are
"blue", I'm not sure how I would answer the second part of the question,
but it would probably involve the dictionary tables and PROC SQL.


--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA

Coelum, non animum mutant, qui trans mare currunt.

>>> "Bhavani Shankar" <bhavani.shankar@INDIA.BIRLASOFT.COM> 12/28/04
10:16 PM >>>
This will solve your problem

Proc Sql;
       Create table new.table as select * from old.table where 1=2;
quit;

Bhavani

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
William Krause
Sent: Wednesday, December 29, 2004 3:29 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Creating an empty SAS data set


How do I create an empty data set using the variables from an existing
data set?

There are 100's of variables in the existing sas dataset.

Also there are two distinct categories of variables - as black and blue
in the
existing SAS data set.

Therefore I want one SAS data set with only black variables
and a second SAS data set with only blue variables.

How can this be accomplished?  I prefer not to use Proc Append with the
Force option.

TIA

wkrause2003@yahoo.com



---------------------------------
Do you Yahoo!?
 Dress up your holiday email, Hollywood style. Learn more.



"MMS <firsthealth.com>" made the following annotations.
------------------------------------------------------------------------------
This message, including any attachments, is intended solely for the use
of the named recipient(s) and may contain confidential and/or
privileged information.  Any unauthorized review, use, disclosure or
distribution of this communication(s) is expressly prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy any and all copies of the original message.
Thank you.
==============================================================================
0
JackHamilton (922)
12/29/2004 6:42:52 AM
comp.soft-sys.sas 142827 articles. 3 followers. Post Follow

1 Replies
501 Views

Similar Articles

[PageSpeed] 10

Hi,

Another way to solve tha problem would be just using a datastep with a obs=0
option:

data new; set old(obs=0);
run;

But probably it will be as costly as using the proc sql with like option.
Also if you have figured out variables which are Black and which are Blue,
then you can use the output comand like:

data new1 new2; set old (obs=0);
if black then ourput new1;.......

Hope this is helpful.

-Shantanu





----Original Message Follows----
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Creating an empty SAS data set
Date: Tue, 28 Dec 2004 23:42:52 -0700

I don't think your solution addresses the second part of the original
question, only the first part.

There are at least two other ways in SQL to do what your code does:

    create table new as select * from old (obs=0);

    create table new like old;

In general, though, if you want to create one table that's exactly like
another data set, you would need to use PROC COPY, which can also create
the indexes and constraints in the original data set.

Without knowing how to tell which variables are "black" and which are
"blue", I'm not sure how I would answer the second part of the question,
but it would probably involve the dictionary tables and PROC SQL.


--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA

Coelum, non animum mutant, qui trans mare currunt.

 >>> "Bhavani Shankar" <bhavani.shankar@INDIA.BIRLASOFT.COM> 12/28/04
10:16 PM >>>
This will solve your problem

Proc Sql;
        Create table new.table as select * from old.table where 1=2;
quit;

Bhavani

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
William Krause
Sent: Wednesday, December 29, 2004 3:29 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Creating an empty SAS data set


How do I create an empty data set using the variables from an existing
data set?

There are 100's of variables in the existing sas dataset.

Also there are two distinct categories of variables - as black and blue
in the
existing SAS data set.

Therefore I want one SAS data set with only black variables
and a second SAS data set with only blue variables.

How can this be accomplished?  I prefer not to use Proc Append with the
Force option.

TIA

wkrause2003@yahoo.com



---------------------------------
Do you Yahoo!?
  Dress up your holiday email, Hollywood style. Learn more.



"MMS <firsthealth.com>" made the following annotations.
------------------------------------------------------------------------------
This message, including any attachments, is intended solely for the use
of the named recipient(s) and may contain confidential and/or
privileged information.  Any unauthorized review, use, disclosure or
distribution of this communication(s) is expressly prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy any and all copies of the original message.
Thank you.
==============================================================================
0
12/29/2004 3:08:14 PM
Reply: