Announcement

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

  • #16
    That's the error message:

    Code:
    invalid syntax
    post:  above message corresponds to expression 3, variable meany
    r(198);
    I understood that Stata is not able to associate the local `cnt'_`yrs'_mdy with the variable meany.

    Comment


    • #17
      Your post #15 tells us you are trying to use postfile to create the file you want rather than the file postfile can easily create, which can then be easily transformed into the file you want using the reshape command.

      In post #5 I asked "Have your do-file use postfile to create a new dataset with variables identifying the country, year, and scenario, and variables containing each of the 10-20 values that your do-file calculates for that country/year/scenario." and it not until post #15 that we see you are not doing that at all.

      The file you describe is in what we would call a "wide layout". As with so many things in Stata this problem appears complicated only because of the wide layout.

      The file I describe in post #5 is in a "long layout". The experienced users here generally agree that, with few exceptions, Stata makes it much more straightforward to accomplish complex analyses using a long layout of your data rather than a wide layout of the same data.

      You should use postfile to create a file in a long layout and then try to achieve what you need with the data organized in that way, and seek the help of Statalist in doing so. The sort of problems you will encounter trying to use your data in a wide layout will almost certainly be solved by reshaping the data back to a long layout. It is much easier, for example, to compare the second observation to the first, the third to the second, and so on, than it is to compare the second variable to the first, the third to the second, etc.

      It appears to me, going all the way back to post #1, that your data is by country and year. That is, for each country and year, you will have observations of a number of variables. (Post #15 suggests that it is more complicated - country, year, group, and step - but the principle is the same.) That is "longitudinal data", and Stata has a collection of commands designed specifically for the analysis of longitudinal data and panel data. They are described in the Stata Longitudinal-Data/Panel-Data Reference Manual PDF included in your Stata installation and accessible through Stata's help menu. What they have in common is the organization of their data in a long format.

      If I am correct that you are going to be analyzing data in a long format, you should spend time reviewing the introductory material on the first 10 or so pages of that PDF. You apparently have been trying to create the dataset you think you will need rather than the dataset that will serve your purposes.

      With that said, the process I described in post #14 includes at this point step 2.3 "In your Do-file Editor window copy the entire contents and paste it into the post using CODE delimiters".

      Comment


      • #18
        I have something like 5,000 datasets, each of them is titled country_year_group_step. I haven't variables describing country, years, groups, steps: just the file names.
        I'd like to create a dataset with a variable for country, a variable per year, and a varibale for each statistics I've created in the previous part of the .do file.

        I'm not an "experienced user" of Stata: I'm trying to expose my point and interpret your suggestions. Therefore, I apologize if I misundertood your questions and/or suggestions.
        Now, is postfile the right command to do what I'd like to do?

        Comment


        • #19
          Now, is postfile the right command to do what I'd like to do?
          Maybe. Post the code as requested in post #18. Your descriptions are not sufficient to know if there is a better way than using postfile.

          I am not an experienced user of your data. I'm trying to interpret your descriptions but they change over time. Don't tell me what you think I need to know, what you think is an adequate description or an appropriate simplification. At this point, I need to see your entire code from top to bottom to be sure I understand what you are attempting to do.
          Last edited by William Lisowski; 26 Feb 2020, 05:14.

          Comment

          Working...
          X