Section 7 Exercises

7.1 GSS Mini Report

Task

Working in your “GSS Mini Research Report Team”:

  1. Pick one variable from the 2016 General Social Survey (GSS2016.dta) that makes sense in a pie chart
  2. Enter the variable name in PollEverywhere
  • Your team’s variable must be unique
  • Both team members should submit it
  1. Make the pie chart in Stata
  2. Save it wherever you want on your computer, as .png or .jpg (NOT as a Stata graph—nothing except Stata can open those)
  3. Go to the “First (mini) research report” issue on the exercises repo, https://github.com/ecn310/exercises/discussions/4
  4. Write and submit your report on the Github discussion
  • One report per team
  • Instructions are in the first post
  • I’ll put an example in the first comment on the issue

How to access and analyze the data

  1. Navigate to the exercises repo on Github
  2. In the list toward the left of the screen, click on GSS2016.dta
  3. Click on “View raw” or the download symbol all the way on the right of the gray “Code” bar
  4. Save the file to your computer, noting the location you save it to
  5. Navigate to where you saved the file and double-click on it (this only opens Stata because it’s a .dta)
  6. Explore the data in Stata. Use browse to see the data, use describe or describe, short to get a summary of the data file.
  7. Explore one variable by using codebook varname, where you input the name of your variable where “varname” is to get an understanding of your variable. Use tabulate varname to see what the observations for that variable look like.

Make a pie graph

  • Use graph pie, over(worryjob) to make a pie chart.

    • Use help graph pie to view documentation on the graph pie command.
  • Use graph pie, over(worryjob) title("How many people worry about losing their job?") to add a title.

  • Use graph pie, over(worryjob) title("How many people worry about losing their job?") plabel(_all percent)to add percentages

  • Finally, use graph export "C:\Users\...\pie_worryjob.png",as(png), replace to save the graph as an image file. Ensure that you fill in the “…” to match the file path on your computer.

Understand and apply syntax for saving a file

  • graph export is the command to save a graph
  • "C:\Users\krist\OneDrive - Syracuse University\ECN_310\pie_worryjob.png" is the path and file name ON PROFESSOR BUZARD’S COMPUTER, not on yours! You need to customize!
  • , is the required comma between command and options
  • as(png) is the option that saves the file in PNG format
  • replace is the option to write over any existing file in the same location with the same name

Mini Report Improvements

  1. Go to the “First (mini) research report” discussion on the exercises repo
  2. Can anything else be improved? How about making the pie chart smaller?
  3. Make .do file that produces the image in your post (detailed instructions on next slide)
  4. Upload your do-file to the GSS_mini_report folder (detailed instructions in two slides)
  5. As a reply (leave your original post alone!!!) to your original comment, post improved version:
  • image is smaller;
  • image matches .do file;
  • has new sentence at the bottom that says something like “The code that created this pie chart is here” where “here” is a link.

You will make a .do file that produces the image in your post. Professor Buzard will run it and make sure your code works/matches what’s in your post. Start by… - Opening Stata, choose Window menu, then Do-File Editor, then New Do-File Editor - The first line of your .do file should be the command to open the data - Insert code to produce the same pie chart from last week - End the file with command to save the pie chart at end - Save file as name1_name2.do (e.g., Dylan_Soph.do) to your computer - Then, upload your do-file to the GSS_mini_report folder: - Navigate to GSS_mini report folder of the exercises repository - Above the list of files, select the Add file dropdown menu and click Upload files. - Alternatively, you can drag and drop files into your browser. - To select your do-file for upload, drag and drop the file, or click choose your files - In the “Commit message” field, type a short, meaningful commit message - Below the commit message fields, choose “Commit directly to the main branch” - Click “Commit changes” - Refresh the GSS_mini_report page and click on your file to make sure it looks right - Copy the url to add to your post on the discussion

7.2 Synching to GitHub Desktop

  1. Click on Current repository near the top left of Github Desktop.
  • If exercises is in the list, click on it
  • If exercises is NOT in the list but you think you cloned the exercises repo last Wednesday (that is, the folder is somewhere on your computer):
    • Click File, click Add local repository, navigate to the folder, click Add repository
    • Don’t give up too easily searching for it. 50% of Github problems come from accidentally downloading the same repo to multiple locations—do everything you can to avoid this
  • If you didn’t clone the exercises repo yet:
    • Click File, click Clone Repository, enter URL of your repo, choose where to save it (again, I suggest on OneDrive), click Clone
  1. Make sure your “current repository” is set to exercises and synch
  • Leave “current branch” set to main
  • Look at the box to the right of “current branch”
    • It may say “Pull origin” or “Fetch origin”
    • Regardless, click the button.
    • Wait for Github Desktop to sync your files.
    • If it doesn’t sync the first time, click the button one more time
  • Once that third box says “Fetch origin; Last fetched just now”, click “History” toward the left of your screen
    • This shows the same commit history as on the web interface
    • Verify by clicking “View on Github” in the middle of the screen
  • Click “Show in Explorer” in the middle of your screen
    • This will show you all the files on your local computer, and they should match what you see on the web interface.
  1. Create a new .do file, save to local exercises repo
  • Add just one line of text, something like “I’m going to upload this .do file to Github!”
    • Add an asterisk at the beginning of the line; this will make it turn green—it’s a “comment” in the code
  • Save the file as yourname.do (e.g., Ryan.do) in the push_to_Github folder in the exercises repo ON YOUR COMPUTER
  • In Github Desktop, Changes on the left of the screen should now have a little “1” in a circle, and your file showing up below with a green plus sign next to it
  1. Use Github Desktop to upload a file
  • In Github desktop:
    • Write a commit message near the bottom left, in the line above “Description.”
    • Make it something specific, like “Add Ryan’s .do file for push-to- Github assignment”
    • You can leave the “Description” box blank—unless you need to add more detail to your commit message
  • Click Commit to main
  • Click Push origin
  • Click View on Github
  • Navigate to the Push_to_Github folder
  • Verify that your “push” worked by clicking on your file name and viewing its contents.
  • If it’s there and has a line of content, you’re done!