SAS code to create a blank dataset with 5 variables and 10 observations.

Reply
Occasional Contributor
Posts: 13

SAS code to create a blank dataset with 5 variables and 10 observations.

Hello All,

 

can someone suggest me a sas code to create a blank dataset with 5 variables and 10 observations.

Its urgent..!! 

 

thanks in advance

PROC Star
Posts: 653

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

When you say blank, do you mean a dataset with all missing values?

Occasional Contributor
Posts: 13

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Yes..Correct..

Super User
Posts: 7,447

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

If it has 10 observations, it sure won't be "blank". In terms of datasets, I would reserve that word for a dataset that has only structure, but no observations.

If you just want 10 observations of missing variables, write a data step that has a format statement for your variables and does 10 outputs.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 7,437

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Here is one way:

data want;
  format a b c $2.;
  format d e 8.;
  do _n_=1 to 10;
    output;
  end;
run;

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 13

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Thank you so much.. Smiley Happy

Super User
Super User
Posts: 7,720

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Seriously though, why are you creating blank datasets.  This not only creates this work (and question) but also creates the other question of how to remove them per you other post.  What is it your trying to do, there will be far better methods than creating loads of blank datasets and then deleting them, thats just a waste of processing power.

Contributor
Posts: 37

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

[ Edited ]

/* you can use the below simple code as well */

 


data z;
input id1$ id2$ id3$ id4$ id5$;
cards;
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
a b c d e
;
run;

 

data blank;
set z;

id1="";
id2="";
id3="";
id4="";
id5="";
run;

Super User
Super User
Posts: 6,848

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Why?

data want;
  length var1-var5 $10;
  do _n_=1 to 10; output; end;
run;
Contributor
Posts: 37

Re: SAS code to create a blank dataset with 5 variables and 10 observations.

Tom,

 

I am new to SAS i just tried to create blank dataset with 5 var and 10 obs.

Ask a Question
Discussion stats
  • 9 replies
  • 415 views
  • 2 likes
  • 7 in conversation