DATA Step, Macro, Functions and more

Create a blank observation

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Create a blank observation

[ Edited ]

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


Accepted Solutions
Solution
‎03-15-2017 01:01 AM
Trusted Advisor
Posts: 1,579

Re: sas

[ Edited ]

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


All Replies
Trusted Advisor
Posts: 1,579

Re: sas

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 ?

Occasional Contributor
Posts: 11

Re: sas

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

Solution
‎03-15-2017 01:01 AM
Trusted Advisor
Posts: 1,579

Re: sas

[ Edited ]

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.

Occasional Contributor
Posts: 11

Re: sas

Thank U very mucH...

Super User
Super User
Posts: 7,977

Re: sas

Please mark @Shmuel's answer as correct.

Super User
Posts: 19,839

Re: Create a blank observation

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. 

Super User
Posts: 11,343

Re: Create a blank observation

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 522 views
  • 2 likes
  • 5 in conversation