Hi there,
Can someone please tell me how to insert a blank line after each by group. Sorry I could not come up with any code but if you can write the code with sashelp.class table that would be great.
If it is not possible to do it on sas table please show me how to write that option during exporting to excel.
Thanks,
This might do:
proc sort data=sashelp.class out=class; by sex age; run;
data want;
set class;
by sex age;
output;
if last.age then do;
call missing(of _all_);
output;
end;
run;
This might do:
proc sort data=sashelp.class out=class; by sex age; run;
data want;
set class;
by sex age;
output;
if last.age then do;
call missing(of _all_);
output;
end;
run;
Look more carefully at the code you have written and follow the logic of it. Proper indentation will help.
data want;
set class;
by sex age;
output;
if last.age then do;
call missing(of _all_);
output;
IF first.ID THEN count=1;
ELSE count+1;
end;
run;
Let's just assume that you meant first.sex instead of first.id
Notice how the test for first.sex is inside block that only runs at last.age. So that can only be true when first age group in that sex group has only one observation.
Also notice how the variable COUNT is incremented after the record has already been output.
It is not clear what you want to count, but the CALL MISSING() is going to blank out the COUNT variable with all of the rest.
But my real question is why the heck would you want to add blank observations? Are you just trying to produce a report? PROC PRINT and PROC REPORT can produce reports that insert blank lines after the groups.
proc sort data=sashelp.iris out=iris;
by species;
run;
data want;
do until (last.species);
set iris;
by species;
output;
end;
call missing(of _all_);
output;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.