BookmarkSubscribeRSS Feed
Jannet
Obsidian | Level 7

Dataset : Have (It contains two blanks observation)

   A B C D

1 A 1 1 1

2 B 2 2 2 

3 C 2 2 2

4 D 4 5 5

5 E 8 8 8

6 F 8 8 8

7         

8 J 8 8 8

9

10 K 7 7 7

 

Dataset, Want

4 D 4 5 5

5 E 8 8 8

6 F 8 8 8

9

10 K 7 7 7

8 J 8 8 8

1 A 1 1 1

3 C 2 2 2

7

2 B 2 2 2

 

Can you please help me in output

 
 
10 REPLIES 10
Jannet
Obsidian | Level 7
@Kurt_Bremser, there s no such rule...i want to break or give space between few observations. So i added two extra rows with blanks to the dataset but now i am struggling to rearrange as per my requirement
Kurt_Bremser
Super User

Then what is the "requirement"?

Keep in mind that coding means algorithm, which is defined as a sequence of clearly defined instructions. Without knowing such instructions, no code can be made.

 

Jannet
Obsidian | Level 7

Actually, i am creating demographic table for the first time and got the following output.

Jannet_0-1603795377109.png

so now, i want to rearrange the order of the rows as per the below and give the break between the observations

Jannet_1-1603795428889.png

Thank you

 

 

Kurt_Bremser
Super User

Please supply the dataset in your picture in usable form (data step with datalines, do not skip this!), so we can exactly see what is in the data and provide code for that.

 

Basically, I would create a new group variable that selects the three sub-reports and use a break in PROC REPORT to create the empty space.

In fact, one might be able to do that from the original raw data, so you should include an example for that also.

ballardw
Super User

@Jannet wrote:
@Kurt_Bremser, there s no such rule...i want to break or give space between few observations. So i added two extra rows with blanks to the dataset but now i am struggling to rearrange as per my requirement

Generally not a good idea to create data that way. Such "rows" can seriously affect the results of statistical computations and become very "fragile" when other data manipulation must be done when you get into "do this except for ... rows".

 

Report procedure can do things like insert blank lines between groups of values IF there can be a rule applied to create the group. Computer code works on rules, not "because I say so". You have to express the rule in terms a computer understands.

PeterClemmensen
Tourmaline | Level 20

What is the logic here? Seems like just a random shuffle of the data?

Jannet
Obsidian | Level 7

@PeterClemmensen yes...actually this is dummy dataset which i created...i want to give blank line between few observation

PeterClemmensen
Tourmaline | Level 20

I see very little reason to do this. However, see if this helps you...

 

data want;
   set sashelp.class;
   if _N_ in (5, 10) then do;
      output;
      call missing(of _ALL_);
      output;
   end;
   else output;
run;
Kurt_Bremser
Super User

If you just want a random shuffle, create a random variable, and sort by it:

data have;
infile datalines truncover;
input A $ B C D;
datalines;
A 1 1 1
B 2 2 2 
C 2 2 2
D 4 5 5
E 8 8 8
F 8 8 8
        
J 8 8 8

K 7 7 7
;

data rand;
setbhave;
x = rand('uniform');
run;

proc sort
  data=rand
  out=want (drop=x)
;
by x;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 10 replies
  • 2024 views
  • 0 likes
  • 4 in conversation