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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 889 views
  • 2 likes
  • 3 in conversation