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
So what is the rule that guides the re-ordering?
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.
Actually, i am creating demographic table for the first time and got the following output.
so now, i want to rearrange the order of the rows as per the below and give the break between the observations
Thank you
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.
@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.
What is the logic here? Seems like just a random shuffle of the data?
@PeterClemmensen yes...actually this is dummy dataset which i created...i want to give blank line between few observation
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.