BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10

I want 19 datasets using sashelp.class

I mean each observation as one dataset

And also how to find no of obs in unknown dataset

Thank u 

Anand

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Mind that most people here have an aversion against assisting people in being idiots, so forget that brain-dead splitting idea.

 

If it is an interview question, the proper answer is "don't do it, as it's a useless waste of time and therefore the employer's money".

View solution in original post

9 REPLIES 9
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

To get the number of obs in a SAS dataset use Proc Contents.

proc contents data=sashelp.class;
run;


 

BrahmanandaRao
Lapis Lazuli | Level 10

Another way 

Usuing

PeterClemmensen
Tourmaline | Level 20

1) Why on earth do you want a separate data set for each observation?

 

2) There are several ways to do this. Here are two..

 

data _null_;
   if 0 then set sashelp.class nobs=nobs;
   call symputx('nobs', nobs);
run;

%put &nobs.;

data _null_;
   dsid=open('sashelp.class');
   nobs=attrn(dsid, 'nobs');
   rc=close(dsid);
   put nobs;
run;

 

BrahmanandaRao
Lapis Lazuli | Level 10

Usung macro s do loop

 

PeterClemmensen
Tourmaline | Level 20

What do you mean? You have to be more specific than this.

BrahmanandaRao
Lapis Lazuli | Level 10

 Ok thank you

Bu i want split 19 datasets 

Each obs as one dataset

 

Using sashelp.class library

 

Kurt_Bremser
Super User

Mind that most people here have an aversion against assisting people in being idiots, so forget that brain-dead splitting idea.

 

If it is an interview question, the proper answer is "don't do it, as it's a useless waste of time and therefore the employer's money".

Kurt_Bremser
Super User

Retrieve the number of observations from dictionary.tables (with SQL).

Splitting datasets is not helpful in >90 % of cases, and with a small dataset like sashelp.class it's plain stupidity.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

splitting a datasets would be more for a process of bills payed and bills not payed from a dataset bills due during "this month".

Why make your life more complicated that it is.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 9 replies
  • 1977 views
  • 1 like
  • 4 in conversation