is2024q2.RData
///////////////////////////////

a<-load("is2024q2.RData")
print(a)
dim(.x)
  [1] 161567      6

head(.x)

  TICKER  CIK                NAME   PERIOD
1    ABT 1800 ABBOTT LABORATORIES 20240331
2    ABT 1800 ABBOTT LABORATORIES 20240331
3    ABT 1800 ABBOTT LABORATORIES 20240331
4    ABT 1800 ABBOTT LABORATORIES 20240331
5    ABT 1800 ABBOTT LABORATORIES 20240331
6    ABT 1800 ABBOTT LABORATORIES 20240331
                                                                                      PLABEL           VALUE
1                                                                          Taxes on earnings  244000000.0000
2 Average Number of Common Shares Outstanding Plus Dilutive Common Stock Options (in shares) 1751715000.0000
3                                                                               Net Earnings 1225000000.0000
4                                                                   Research and development  654000000.0000
5                                   Diluted Earnings Per Common Share (in dollars per share)          0.7000
6                                                                          Taxes on earnings  211000000.0000



/////////////////////////////////

why a temporary file
////////////////////////////////

Firstly, tempfile() generates a unique and temporary file name, ensuring no name collisions
   or overwrites. This is particularly useful when you need a temporary file for intermediate
   calculations or storage. 

Secondly, since tempfile() creates files with unique names, it reduces the risk of accidentally
   overwriting important files. 

Thirdly, using tempfile() simplifies the process of managing temporary files. 

Fourthly, we don't need to specify a location or handle the file creation process manually. 

Finally, after quitting R, the temporary file will vanish automatically. 

////////////////////////////////

Generate BS, IS, CF for 2024Q2
///////////////////////////////
setwd("c://yan/teaching/fmr/_backup/data/sec_fin_statement_data_sets/2024q2/")
sub <-read.delim2("sub.txt",header = TRUE) 
pre <-read.delim2("pre.txt", header = TRUE) 
num <-read.delim2("num.txt", header = TRUE)  
#
m1<-merge(sub,pre)  
m2 <-merge(num,m1)  
#
d<-load("../tickerCik.RData") # print(d) head(.x)
a<-.x[,1:2]
period<-"2024q2"
#
fun3<-function(data,name,yearq){  # name BS  yearq 2024q2
  if(toupper(name)=="BS"){
     d0<-subset(data,stmt=="BS",select =c(cik,tag, plabel,value,report,line,name,period,ddate))  
  }else if(toupper(name)=="IS"){
     d0<-subset(data,stmt=="IS",select =c(cik,tag, plabel,value,report,line,name,period,ddate))  
  }else{
     d0<-subset(data,stmt=="CF",select =c(cik,tag, plabel,value,report,line,name,period,ddate))  
  }
  d <- d0[order(d0$name, d0$report, d0$line),]
  rownames(d)<-NULL
  colnames(d)<-toupper(colnames(d))
  b<-merge(d,a)
  .x<-data.frame(b$TICKER,b$CIK,b$NAME,b$PERIOD,b$PLABEL,b$VALUE)
  names<-gsub("^b.","",colnames(.x))
  colnames(.x)<-names
  outfile<-paste0("c://temp/",name,yearq,".RData")
  save(.x,file=outfile)
}
#
fun3(m2,"bs",period)
fun3(m2,"is",period)
fun3(m2,"cf",period)
/////////////////////////////////