BookmarkSubscribeRSS Feed
Anandkvn
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
PROC Star

And what exactly is your problem with the task?

 

Anandkvn
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
PROC Star

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.

Anandkvn
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

@Anandkvn 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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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