02-03-2018 11:32 AM
I have a task which I couldn't tackle. I have a data set that includes patient's ID and several variables coding patient's outcome performance on different scales before, during and after an intervention. The grade of performance is coded from 0 to 4. Performance outcomes are partially missing for some patients.
I want to build a line chart that shows the change in the percentage of patients that have a performance grade 3 or 4 before, during and after the outcome.
My data look like this:
Data x; input ID test1before test1during test1after test2before test2during test2after ... .. testNafter; cards; 1 1 2 3 1 3 3 ... 3; 2 . 1 2 1 4 4 ... 4; 3 3 4 4 1 3 3 ... 2; . . . ; end;
I have a number of difficulties. I think the best way is to make a new data set that contains the percentage of performance grade 3 or 4 for a each test on before, during and after the intervention, but I did not find the right procedure. Such data set will look like this:
Test Before During After
Test1 30% 55% 50%
Test2 20% 43% 38%
The percentage need to be calculated after excluding missing values.
Can you please help me?
02-05-2018 12:09 PM
I might suggest the Test number be just that unless you have much more information involved than "Test1".
The overall data for graphing is likely to look more like but you don't mention what your "line chart" should look like. What would the xaxis on your chart represent? The test number?
Test Period Value
Test1 Before 30%
Test1 During 55%
Test1 After 50%
Are asking for help on calculating percentages? What would the numerator and denominator be for the percentages?
Note your cards statements are incorrect as you cannot have the ; ending them and the data step would end with Run, not end.
Here is my guess as to what you might be attempting:
Data x; input ID before1 during1 after1 before2 during2 after2 ; array t before: during: after: ; /* create 1/0 coded values, mean will be decimal percentage*/ do i= 1 to dim(t); t[i] = t[i] in (3,4); end; drop i; cards; 1 1 2 3 1 3 3 2 . 1 2 1 4 4 3 3 4 4 1 3 3 ; run; proc summary data=x; var before: during: after: ; output out= xsum (drop=_type_ _freq_) mean=; run; data plot; set xsum; array b before: ; array d during: ; array a after: ; do Test= 1 to dim(b); When='Before'; Value=B[Test]; output; when='During'; value=D[Test]; output; when='After'; value=a[Test]; output; end; keep test when value; run; proc sgplot data=plot; series x=test y=value /group=when; format value percent8.1; run;