BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
/* create 19 datasets with number */
%macro creatdatasets(ds);
%do i=1 %to 19 ;
if _n_=i then do;
data _&i.;
output;
%end;
%mend;
%put createdataset(sashelp.class);

Hi

Here i want to create 19 datasets each dataset has to be single observations using do loops macro

8 REPLIES 8
andreas_lds
Jade | Level 19

And what exactly is your problem with the task?

 

BrahmanandaRao
Lapis Lazuli | Level 10

Here i am trying to create 19 datasets each dataset should be single observarion

ex ds_1 contains  name sex age height weight 

     .............

     ds_19  

andreas_lds
Jade | Level 19

Try to create one dataset with one obs without any macro-statement. Then identify the statements that need to be dynamic and start replacing.

 

 

 

Kurt_Bremser
Super User

Is this homework?

If yes, start by having working non-macro code which creates one dataset as wanted. Post this code.

 

If not, I seriously question the need for splitting.

BrahmanandaRao
Lapis Lazuli | Level 10
yes its homework could you please give solution
LinusH
Tourmaline | Level 20
First of all, you need a SET statement so you have something to create new data sets from.
Data never sleeps
Kurt_Bremser
Super User

@BrahmanandaRao wrote:
yes its homework could you please give solution

Homework is intended to test your skills, not ours. It is really time now that you start using the most important tool you were given at birth. It sits between your ears and is called a brain.

 

And I have already given you the path to the solution: start with working code for one output file. If, after 4 years and 600 posts here, you still cannot get that extremely simple part done, you have to face the fact that you just haven't got what it takes to work with SAS. Find another endeavor which fits your capabilities.

PaigeMiller
Diamond | Level 26

Why would you (or anyone) want many different data sets each with one observation, rather than one large data set with all observations? Many data sets with one observation each will be a nightmare to work with, compared to everything in one large data set.

 

If this is homework, then shame on your instructor for asking you to do something that likely will never be needed.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1324 views
  • 3 likes
  • 5 in conversation