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

Hi!

 

I have a SAS file of 200 zones. In each zone, there are 150 houses. I then have a binary event variable. 

I do not have info on all the houses but need to fill in the missing values and put event= '.'

Like for zone 0, I am missing house 4,5,6,7, the values between 8-30, etc. Is there a way I can add these missing values for each of the zones in SAS?

 

I hope this question makes sense!

 

the picture is how it looks now:

thumbnail_Screen Shot 2019-06-13 at 3.20.41 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

We know that there are 150 houses per zone.

So houses are labeled 0 to 150 and how many zones do you have?

 

Probably the simplest way is to build an empty table and merge into it.

 

data skeleton;
do zone=1 to 200;
do house=1 to 150;
output;
end;
end;
run;

data want;
merge skeleton have;
by zone house;
run;

 

A bunch of other options are outlined in this document, some are easier, some are harder.

https://www.lexjansen.com/pharmasug/2005/CodersCorner/cc22.pdf

View solution in original post

5 REPLIES 5
Reeza
Super User
Sure, but you need to have the infomration somewhere? Does it exist elsewhere in a different data set? How do you know which values are missing besides obvious sequential order? For example,should 90 to 101 be present for zone 2?

There's a CLASSDATA option in PROC MEANS that helps with setting this up.

We can't really help from images though, unless we type out your data. If you need help with code please take the time to paste your data as text and also show your expected output.
CMepistudent
Calcite | Level 5

I already have this file imported into SAS.

We know that there are 150 houses per zone. So for the houses with missing info: I need it to say zone 0, hour 4, accident "." (to indicate that it's missing). 

 

We have information for a lot of the houses, but need to indicate missing for the ones that aren't listed in the file. 

 

Reeza
Super User

We know that there are 150 houses per zone.

So houses are labeled 0 to 150 and how many zones do you have?

 

Probably the simplest way is to build an empty table and merge into it.

 

data skeleton;
do zone=1 to 200;
do house=1 to 150;
output;
end;
end;
run;

data want;
merge skeleton have;
by zone house;
run;

 

A bunch of other options are outlined in this document, some are easier, some are harder.

https://www.lexjansen.com/pharmasug/2005/CodersCorner/cc22.pdf

CMepistudent
Calcite | Level 5

Thank you! I appreciate it!

PGStats
Opal | Level 21

Can't do any testing with a picture.

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1584 views
  • 2 likes
  • 3 in conversation