BookmarkSubscribeRSS Feed
Ankur32
Obsidian | Level 7

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

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

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

Kurt_Bremser
Super User

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.

art297
Opal | Level 21

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

Ankur32
Obsidian | Level 7

Thank you so much.. 🙂

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

shivamarrora0
Obsidian | Level 7

/* 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;

Tom
Super User Tom
Super User

Why?

data want;
  length var1-var5 $10;
  do _n_=1 to 10; output; end;
run;
shivamarrora0
Obsidian | Level 7

Tom,

 

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

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, 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
  • 9 replies
  • 16978 views
  • 3 likes
  • 7 in conversation