For those of you who know R and who want to look up the code/label for a single PUMS variable here is some code that uses the "metadata" api
you need "jsonlite"
install.packages("jsonlite") to install
The blog interface messes up the R code paste with the url .
replace H-T-T-P-S with https.
# Example Call: gpcv<-get.pums.codebook.variable("PERNP",vintage=2020,period=5,debug=1)
get.pums.codebook.variable<-function(vname="LNGI",vintage="2021",period="1",debug=0) {
vname<-toupper(vname);
url<-paste("h-t-t-p-s://api.census.gov/data/",vintage,"/acs/acs",period,"/pums/variables.json",sep="");
if(debug) cat("get.pums.codebook.variable: url=\n",url,"\n",sep="");
require("jsonlite");
r<-try(jsonlite::fromJSON(url));
if(class(r)[1]=="try-error") {
cat("get.pums.codebook.variable: Download error: url=\n",url,"\n",sep="");
return(2);
}; # if class
variables<-r$variables;
nmv<-toupper(names(variables));
m<-match(vname,nmv);
if(any(is.na(m))) {cat("get.pums.codebook.variable: ERROR variable: ",vname,"not matched.\n");return(1);};
vm<-variables[[nmv[m]]];
val<-vm[["values"]];
items<-val[["item"]];
nmi<-names(items);
cb<-NULL;
M<-length(nmi);
if(M>0) {
lab<-rep("",M);
for(j in seq(1,M)) {
lab[j]<-items[[j]];
}; # for j
cb<-data.frame(code=nmi,value=lab);
}; # # M > 0
rng<-val[["range"]];
invisible(list(variable=vname,label=vm$label,codes=cb,range=rng,type=vm$predicateType));
}; # get.pums.codebook.variable
Enjoy
If you want to contact me with comments or bug reports:
info@dorerfoundation.org
Note this was updated 12-21-2022 at 3:47 pm EST
Note I've found 2 bug so far.. If you downloaded earlier, please update.
Dave