0

I have 3 data sets: "Complete", "Incomplete", and "Case_List". "Complete" contains records of individuals that have had a full series of a vaccine; "Incomplete" is identical except that the number of doses is less than the full series; and "Case_List" contains confirmed cases of a specific infection. Each data set contains a date, which I have transformed into week of the year (1:53), the individuals age, which I have divided into age groups(easiest to refer to age groups as 1:8, but their character variables), and an ID. Every ID/record in "Complete" is, by definition, in "incomplete" as the individual received dose 1 before dose 2, but I don't have access to any personal identifiers to link them to the "Case_List" ID's.

I am new to SAS and have yet to find enough instruction on plotting to be able to plot a graph with the Case_List over Week(1:53) overlayed with Incomplete over Week(1:53) and Complete over Week(1:53), and all of that broken down by Age_Group(1:8). If I can't get it figured out, I will just plot everything in R.

Other thoughts: Is it easier to merge Incomplete and Complete so there are only two data sets? Is 8 iterations of a graph that already contains 3 lines going to be too messy for one plot?

Thanks for your help.

  • 1
    It's very difficult to visualize what you're trying to do without sample data and a mockup of the graph you'd like to have in `sgplot`. – Stu Sztukowski Jun 11 '21 at 01:37
  • would a person with no doses appear in the *Incomplete* data set ? Do you want bar charts ? Series plots overlaying bar charts ? With 3 status categories and 8 age sub-categories you might want to use `SGPANEL` and `PANELBY age` and plot the status counts by week within each panel. The plotting statements might be easier if you pre-aggregate your individual records into status + age combination frequency counts. If case_list contains no age information you may want a separate panel for just case counts. – Richard Jun 11 '21 at 09:14

1 Answers1

1

In SAS, you can't overlay plots from multiple datasets - you need to combine everything into one dataset.

You don't have to "merge" anything, though, just set them together and add a "category" variable.

data incompletes completes case_list;
    call streaminit(7);
    do week = 1 to 53;
      do _i = 1 to 200;
        age = rand('Integer',1,8);
        _output = rand('Uniform');
        if _output lt (0.1+week/100) then output completes;
        if _output lt (0.2+week/80) then output incompletes;
        if _output lt (0.2-((week/150)**2)) then output case_list;
      end;
    end;
run;



data total;
  set completes(in=_comp) incompletes(in=_incomp) case_list(in=_case);
  if _comp then category="Complete";
  else if _incomp then category="Incomplete";
  else category="Disease Cases";
run;
    
    

Then you can overlay plots, depending on exactly what you want to do.

proc sgplot data=total;
  vline week/group=category;
run;

You could add paneling by age as noted in the comments, or you have a few other options depending on what exactly you do, but I think this gets at what you really want to know - how do I overlay plots in SAS.

Joe
  • 62,789
  • 6
  • 49
  • 67