BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AbuChowdhury
Fluorite | Level 6

Hi Experts,

I use the following code to insert a blank row for each observation:

 

data want;
set have;
output; /* Output real observation */
if mod(_n_,1)=0;
array allnums {*} _numeric_ ;
array allchar {*} _character_ ;
drop i;
do i=1 to dim(allnums); allnums{i}=.; end;
do i=1 to dim(allchar); allchar{i}=' '; end;
output; /* Output blank observation */

run;
options missing=' '; /* Display numeric missing as blank */

 

 

My question is: How can I insert two or more blank rows for each observation?

Another question is: How can I insert a blank row in the beginning of the dataset?

 

Thanks,

Abu Chowdhury

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

For example:

 

data want;

if 0 then set sashelp.class;

if _n_=1 then do;

call missing(of _all_);

output;

end;

set sashelp.class;

output;

call missing(of _all_);

output;

output;

run;                                                                      

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

I find it incomprehensive to use if  mod(_n_,1)=0, that is anyway going to be 0 for all iteractions when the denominator is 1. 

Secondly, you could simply use call missing(of _all_) and output staments in one shot without having to declare and loop through array elements.

 

Best Regards,

Naveen Srinivaan

novinosrin
Tourmaline | Level 20

For example:

 

data want;

if 0 then set sashelp.class;

if _n_=1 then do;

call missing(of _all_);

output;

end;

set sashelp.class;

output;

call missing(of _all_);

output;

output;

run;                                                                      

Astounding
PROC Star

That's a good set of tools for the job.  Notice also a simplifying possibility:

 

if 0 then set sashelp.class;

if _n_=1 then output;

 

Since the variables are already missing when _n_=1, you don't have to jump through that hoop of setting them to missing.

Reeza
Super User

Why do you nerd blank rows? This is a display issue, so maybe you can add the spaces using PROC REPORT. 

Reeza
Super User

Why do you nerd blank rows? This is a display issue, so maybe you can add the spaces using PROC REPORT. 

Ksharp
Super User
data class;
if _n_=1 then output;
set sashelp.class;
output;
run;
AbuChowdhury
Fluorite | Level 6

Thanks to all of you for your suggestions.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 7 replies
  • 11043 views
  • 4 likes
  • 5 in conversation