Announcement

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

  • Stata not saving correctly

    Hello, I am making changes to a data file then saving under a different name. The file with the new name "demo_working" is not being saved in the same directory (I don't know where it is being saved) from which I took the original file "DEMO_CHARGE_RAW_jm"

    Below is my code. When I open up the demo_working file in the folder "jm_working" it is not saved with the changes that I made.

    Any suggestions?



    use "/Users/u0521032/Library/CloudStorage/OneDrive-UniversityofPittsburgh/LeaRRn-Jake/jm_working/DEMO_CHARGE_RAW_jm.dta", clear

    format %16.0f PAT_ENC_CSN_ID // format enc id

    rename *, lower // all lower case

    capture drop dos_rc //making into usable date
    gen dos_rc = date(orig_service, "DM20Y")
    format dos_rc %td


    keep pat_enc_csn_id - race visit_number dos_rc

    sort pat_enc_csn_id visit_number dos_rc

    order visit_number, after (pat_enc_csn_id)

    capture drop n_1
    by pat_enc_csn_id: gen n_1 = _n

    keep if n_1 == 1

    save demo_working, replace /// removed payment variable

  • #2
    That dataset will be saved in the current directory, which isn't necessarily the same as the directory with the original dataset.

    Code:
    pwd
    will tell you where that is. If it is too late to do that, I guess you'll need to use Unix to find out where it is.

    Comment


    • #3
      Thanks.

      Comment


      • #4
        I changed the director to jm_working and when I use the command save demo_working it still does not save it as demo_working. In fact it leaves the name as DEMO_CHARGE_RAW_jm as the title of the data file in the open Stata window. Any thoughts?

        Comment


        • #5
          Your new code, please?

          Comment


          • #6
            cd "/Users/u0521032/Library/CloudStorage/OneDrive-UniversityofPittsburgh/LeaRRn-Jake/jm_working"
            /Users/u0521032/Library/CloudStorage/OneDrive-UniversityofPittsburgh/LeaRRn-Jake/jm_working



            use "/Users/u0521032/Library/CloudStorage/OneDrive-UniversityofPittsburgh/LeaRRn-Jake/jm_working/DEMO_CHARGE_RAW_jm.dta", clear

            format %16.0f PAT_ENC_CSN_ID // format enc id

            rename *, lower // all lower case

            capture drop dos_rc //making into usable date
            gen dos_rc = date(orig_service, "DM20Y")
            format dos_rc %td


            keep pat_enc_csn_id - race visit_number dos_rc

            sort pat_enc_csn_id visit_number dos_rc

            order visit_number, after (pat_enc_csn_id)

            capture drop n_1
            by pat_enc_csn_id: gen n_1 = _n

            keep if n_1 == 1

            save demo_working, replace /// removed payment variable

            Comment


            • #7
              Oh the problem is the /// at the end of your save command. Use two slashes instead. Three slashes means that it is waiting for you to enter another line, which it will then treat as part of your save command. See also

              Code:
              help comments
              Last edited by Hemanshu Kumar; 12 Aug 2022, 09:56.

              Comment


              • #8
                No it does not and when I use the pwc command it says it is saving in the correct folder. Never happened to me before

                Comment


                • #9
                  Sorry pwd command

                  Comment


                  • #10
                    I realised the problem after I posted #7 asking you if there was an error. See the edited version of #7 above.

                    Comment


                    • #11
                      ARGH! What a mistake. Thank you for catching that. It was really perplexing me.

                      Comment

                      Working...
                      X