Skip to content

Commit

Permalink
save to stata dta format also
Browse files Browse the repository at this point in the history
  • Loading branch information
mle2718 committed Oct 28, 2024
1 parent dff4a7a commit 505e5d4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R_code/data_extraction_processing/extraction/pull_in_MRIP.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ raw_mrip_folder<-local_mrip_folder

len_dataset<-list()

year<-as.character(2021:2024)
year<-as.character(2024:2024)
year<-as.data.frame(year)
waves<-as.character(1:6)
waves<-as.data.frame(waves)
Expand All @@ -49,6 +49,7 @@ size_file_in<-file.path(raw_mrip_folder,paste0("size_",waves,".sas7bdat"))
len<-len %>%
rename_with(tolower)
saveRDS(len,file=file.path("data_folder", "raw", paste0("size_",waves,".Rds")))
haven::write_dta(len,path=file.path("data_folder", "raw", paste0("size_",waves,".dta")), version=14)
return(len)
}
}
Expand All @@ -64,12 +65,14 @@ readin_trips <- function(waves) {
trips_file_in<-file.path(raw_mrip_folder,paste0("trip_",waves,".sas7bdat"))

if(file.exists(trips_file_in)==TRUE){
trips<-haven::read_sas(trips_file_in)
trips<-trips %>%
trip<-haven::read_sas(trips_file_in)
trip<-trip %>%
rename_with(tolower)

saveRDS(trips,file=file.path("data_folder", "raw", paste0("trip_",waves,".Rds")))
return(trips)
saveRDS(trip,file=file.path("data_folder", "raw", paste0("trip_",waves,".Rds")))
haven::write_dta(trip,path=file.path("data_folder", "raw", paste0("trip_",waves,".dta")), version=14)

return(trip)
}
}

Expand All @@ -93,6 +96,8 @@ readin_catch <- function(waves) {
rename_with(tolower)

saveRDS(catch,file=file.path("data_folder", "raw", paste0("catch_",waves,".Rds")))
haven::write_dta(catch,path=file.path("data_folder", "raw", paste0("catch_",waves,".dta")), version=14)

return(catch)
}
}
Expand Down Expand Up @@ -121,6 +126,8 @@ readin_sizeb2 <- function(waves) {
lenb2<-lenb2 %>%
rename_with(tolower)
saveRDS(lenb2,file=file.path("data_folder", "raw", paste0("size_b2_",waves,".Rds")))
haven::write_dta(lenb2,path=file.path("data_folder", "raw", paste0("size_b2_",waves,".dta")), version=14)

return(lenb2)
}
}
Expand Down

0 comments on commit 505e5d4

Please sign in to comment.