- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is the dataset - it comes in like this automatically. And the number of rows per hospital changes each month so this is not something I want to manually code each month by saying "if it's rows 1:6 then hospital name = Hospital A". Again, the number of rows per hospital changes monthly.
Is there an array or something that we can do so that "Hospital Name" gets populated with the correct hospital name by saying fill it in with Hospital A until there is no longer a blank, then fill it in with the next name?
Hospital Name Month
Hospital A Jan
Feb
March
April
May
June
Hospital B Jan
Feb
March
Hospital C Jan
Feb
March
April
This is what I want:
Hospital Name Month
Hospital A Jan
Hospital A Feb
Hospital A March
Hospital A April
Hospital A May
Hospital A June
Hospital B Jan
Hospital B Feb
Hospital B March
Hospital C Jan
Hospital C Feb
Hospital C March
Hospital C April
Any insight would be appreciated!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
retain HospitalID;
if not missing(FAC_ID) then HospitalID=FAC_ID;
run;
Those are the two lines you need.
@Krysia24 wrote:
Comes to us as a SAS dataset. Hospital Name is actually "FAC_ID." I did not include the rest of the variables for simplicity but let me know if that's helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This task is relatively easy, but you need to give us information about the data.
"This is the dataset" ==> Is this a SAS data set? If not, where is the program that reads it into SAS?
If this is a SAS data set, what are the variable names? (Do you really have a variable named "Hospital Name" with a blank in the middle of the name?) Does it contain other variables that you haven't shown? (Yes, that makes a difference in terms of which solutions will work properly.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Comes to us as a SAS dataset. Hospital Name is actually "FAC_ID." I did not include the rest of the variables for simplicity but let me know if that's helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
retain HospitalID;
if not missing(FAC_ID) then HospitalID=FAC_ID;
run;
Those are the two lines you need.
@Krysia24 wrote:
Comes to us as a SAS dataset. Hospital Name is actually "FAC_ID." I did not include the rest of the variables for simplicity but let me know if that's helpful.