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

How to insert a blank observation alternatively or every two observations or specified?

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Try next code;

data want;
  set have;
      output;
       if mod(_N_,2) = 0 then do;
           call missing(_ALL_);
           output;
       end;
run;

change the MOD() 2nd argument  to insert blank observation as desired.

View solution in original post

7 REPLIES 7
Shmuel
Garnet | Level 18

The tool to enter a blank observation depends on your source and target -

is it a dataset or a report ? do you have ID (key) variables?

 

and - why do you want to insert the blank observation? what is the goal ?

Ram999
Calcite | Level 5

insert a blank observations alternatively or every 2 observations for existed dataset

Shmuel
Garnet | Level 18

Try next code;

data want;
  set have;
      output;
       if mod(_N_,2) = 0 then do;
           call missing(_ALL_);
           output;
       end;
run;

change the MOD() 2nd argument  to insert blank observation as desired.

Ram999
Calcite | Level 5

Thank U very mucH...

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please mark @Shmuel's answer as correct.

Reeza
Super User

Depends. 

 

Using a do loop op with an explicit output statement and CALL MISSING() is easier option for a dataset. If it's a report there are other options. I suggest you expand upon what you're looking to accomplish. 

ballardw
Super User

Any takers that we will next see a request from OP on how to insert values from another data source into those blank rows?

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
  • 3737 views
  • 2 likes
  • 5 in conversation