Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacing missing values by certain dates

    Hi, I have dataset which has the format as shown in the code below. I would like to replace the missing data for andate by the same value up until new andate. So given the first andate in example is 15714, I want to replace all missing up to the new andate by 15714 and afterwards the second andate 15742 so I want to replace all missing after it by this date and then do this for all andates. Thanks in advance for any help



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int date float andate
    15706     .
    15707     .
    15708     .
    15711     .
    15712     .
    15713     .
    15714 15714
    15715     .
    15718     .
    15719     .
    15720     .
    15721     .
    15722     .
    15725     .
    15726     .
    15727     .
    15728     .
    15729     .
    15732     .
    15733     .
    15734     .
    15735     .
    15736     .
    15739     .
    15740     .
    15741     .
    15742 15742
    15743     .
    15746     .
    15747     .
    15748     .
    15749     .
    15750     .
    15753     .
    15754     .
    15755     .
    15756     .
    15757     .
    15760     .
    15761     .
    15762     .
    15763     .
    15764     .
    15767     .
    15768     .
    15769     .
    15770 15770
    15771     .
    15774     .
    15775     .
    15776     .
    15777     .
    15778     .
    15781     .
    15782     .
    15783     .
    15784     .
    15785     .
    15788     .
    15789     .
    15790     .
    15791     .
    15792     .
    15795     .
    15796     .
    15797     .
    15798 15798
    15799     .
    15802     .
    15803     .
    15804     .
    15805     .
    15806     .
    15809     .
    15810     .
    15811     .
    15812     .
    15813     .
    15816     .
    15817     .
    15818     .
    15819     .
    15820     .
    15823     .
    15824     .
    15825     .
    15826     .
    15827     .
    15830     .
    15831     .
    15832     .
    15833 15833
    15834     .
    15837     .
    15838     .
    15839     .
    15840     .
    15841     .
    15844     .
    15845     .
    end
    format %td date
    format %td andate

  • #2
    You may try something like this:

    Code:
    sort date
    replace andate = andate[_n-1] if missing(andate)
    replace andate = 15714 if missing(andate)
    Best regards,

    Marcos

    Comment


    • #3
      Hi, my dataset has the format as shown in the code below. I would like to replace the missing data for tube date by thesame participants .Thanks in advance for any help






      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input long(tubedate intdte dxdate)
          . 12684 12592
          . 12696 12611
          . 12744 12584
       5036 12718 12586
          . 12708 12625
       7379 12712 12618
          . 12720 12620
          . 12734 12618
          . 12722 12649
          . 12814 12624
          . 12814 12652
          . 12722 12597
          . 12758 12662
          . 12734 12653
          . 12778 12626
          . 12744 12642
          . 12800 12633
          . 12778 12673
          . 12850 12677
          . 12786 12649
          . 12754 12660
       6071 12732 12681
       7471 12758 12572
          . 12758 12638
          . 12780 12677
          . 12758 12582
          . 12818 12694
          . 12816 12689
          . 12750 12634
          . 12778 12698
          . 12778 12694
          . 12958 12712
          . 12840 12732
          . 12914 12715
          . 12816 12733
          . 12856 12683
          . 12830 12704
          . 13150 12583
          . 12892 12607
          . 12814 12673
       3848 12824 12725
          . 12926 12709
          . 13038 12719
          . 12850 12712
          . 12890 12752
       3333 12870 12647
          . 12904 12796
          . 13012 12772
          . 12892 12758
          . 12870 12709
          . 12894 12792
       -108 12898 12809
       2967 12946 12823
          . 12996 12795
          . 12920 12823
          . 12992 12765
          . 12918 12774
          . 12918 12816
          . 13030 12834
          . 13064 12828
          . 12928 12827
          . 12954 12816
          . 13032 12849
          . 12926 12853
          . 13010 12702
          . 12944 12781
       7379 13218 12857
          . 12968 12852
          . 12928 12855
          . 12934 12863
          . 13062 12864
          . 13006 12687
          . 13012 12870
          . 12974 12886
          . 12996 12725
          . 12998 12705
          . 12996 12913
          . 13188 12767
          . 13084 12786
          . 13226 12921
          . 13002 12848
          . 13024 12859
          . 13032 12905
       6589 13002 12872
          . 13000 12880
       2602 12988 12926
          . 13046 12897
      -1022 13036 12794
       1049 13362 12933
          . 13032 12821
          . 13114 12925
       7013 13174 12893
          . 12990 12919
          . 13100 12745
          . 13038 12925
          . 13030 12922
          . 13228 12844
          . 13026 12948
          . 13052 12927
          . 13060 12961
      end
      format %td tubedate
      format %td intdte
      format %td dxdate

      Comment


      • #4
        what is a participant and how do you know when an observation is the "same participant" as another observation?

        Comment


        • #5
          Sorry for not being clear. I have a total of 852 observations with 16 variables 3 of the variables as listed above is responses for dates from the same individuals. Some are missing of
          tubedate, and dxdate but non is missing on intdate. I want to find a time lapse from tubedate to dxdate or intdate.Kindly let me know if this is clear. Thank you!

          Comment

          Working...
          X