02-02-2021
Leon27607
Fluorite | Level 6
Member since
02-25-2012
- 54 Posts
- 2 Likes Given
- 0 Solutions
- 1 Likes Received
-
Latest posts by Leon27607
Subject Views Posted 1300 10-28-2020 12:40 PM 1335 10-28-2020 11:49 AM 1548 07-22-2020 12:43 PM 1582 07-22-2020 06:26 AM 1655 07-21-2020 05:08 PM 1498 08-08-2018 03:37 PM 1501 08-08-2018 03:34 PM 1523 08-08-2018 02:48 PM 5078 01-02-2018 04:54 PM 1727 07-24-2017 04:00 PM -
Activity Feed for Leon27607
- Got a Like for Re: Need help with PSmatch. 03-19-2023 04:09 AM
- Posted Re: WARNING: The quoted string currently being processed has become more than 262 characters long. on SAS Procedures. 10-28-2020 12:40 PM
- Posted WARNING: The quoted string currently being processed has become more than 262 characters long. on SAS Procedures. 10-28-2020 11:49 AM
- Posted Re: Need help with PSmatch on Statistical Procedures. 07-22-2020 12:43 PM
- Liked Re: Need help with PSmatch for Reeza. 07-22-2020 12:43 PM
- Posted Re: Need help with PSmatch on Statistical Procedures. 07-22-2020 06:26 AM
- Posted Need help with PSmatch on Statistical Procedures. 07-21-2020 05:08 PM
- Posted Re: Merging files using "Set" on SAS Programming. 08-08-2018 03:37 PM
- Posted Re: Merging files using "Set" on SAS Programming. 08-08-2018 03:34 PM
- Posted Merging files using "Set" on SAS Programming. 08-08-2018 02:48 PM
- Posted Generating Slope for regression line on Graphics Programming. 01-02-2018 04:54 PM
- Posted Having Trouble with SGPlots colors on Graphics Programming. 07-24-2017 04:00 PM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-21-2017 11:49 AM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-21-2017 11:36 AM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-21-2017 11:34 AM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-21-2017 11:09 AM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-21-2017 09:18 AM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-20-2017 06:23 PM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-20-2017 05:08 PM
- Posted Re: Problem with Proc SGplot in a macro on Graphics Programming. 07-20-2017 05:06 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 2 -
My Liked Posts
Subject Likes Posted 1 07-22-2020 12:43 PM
10-28-2020
12:40 PM
Ah, thanks. I couldn't figure it out because it seemed like the comment was still correct(everything within was still green, and text outside was not).
... View more
10-28-2020
11:49 AM
I've been banging my head for hours trying to find out where in my code this warning is coming from. It's preventing me from continuing since it kind of breaks SAS(I have to close and reopen SAS every time to get things working again). I suspect maybe I'm missing a ; or some sort of statement somewhere because I couldn't find any unclosed quotes. I also don't see where any macro variables could exceed the 262 char limit... I inherited this code from someone else before they left for paternity leave so I've been having to try and figure out what they did but their code isn't working right. If anyone can see what's wrong and help me fix this it'd be greatly appreciated.
%macro var_maker();*<==This is where you would add new criteria. Make sure it has a label otherwise it won't be included in the automated processing;
proc sql;
create table count_sums /* Note that I will need to include order count and refill count */
as select
MRN
,Group_Indicator
,Opioid_or_Benzo
,Report_Date
,sum(Init_fill_and_refills) as fill_refill_count
/* Criteria not combined with fills */
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <274 then 1 else 0 end) >= 1
AND sum(case when 274 <= Report_Date - Ordering_Date_Time <365 then 1 else 0 end) >= 1
then 1 else 0 end as fills_all_quarters label "Orders in All Quarters"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <366 then 1 else 0 end) >= 1
then 1 else 0 end as fills_both_halves label "Orders in Both Halves"
%let i=3;
%do %while (&i <= 12);
/* Criteria combined with fills */
,case when sum(Init_fill_and_refills) < &i then 0
when sum(Init_fill_and_refills) >= &i then 1
else . end as fill_refill_count_&i label "&i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <274 then 1 else 0 end) >= 1
AND sum(case when 274 <= Report_Date - Ordering_Date_Time <365 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_all_quarters_fill_ge_&i label "Orders in All Quarters AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_qneg_1n2_fill_ge_&i label "Orders in -1 and -2 Quarters AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_qneg_1_fill_ge_&i label "Orders in -1 Quarter AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <366 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_both_halves_fill_ge_&i label "Orders in Both Halves AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_halfneg_1_fill_ge_&i label "Orders in -1 Half AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <181 then 1 else 0 end) >= 1 /* First period 180 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last180_fill_ge_&i label "Orders in last 180 AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <121 then 1 else 0 end) >= 1 /* First period 120 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last120_fill_ge_&i label "Orders in last 120 AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <121 then 1 else 0 end) >= 1 /* First period 90 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last90_fill_ge_&i label "Orders in last 90 AND &i Orders or More"
%let i = %sysevalf(&i + 1);
%end;
from data3.analytic_file
group by Opioid_or_Benzo, Group_Indicator, MRN, Report_Date
;
quit;
title "Fill Counts by Opioid/Benzo and Group";
proc univariate data=count_sums;
var fill_refill_count;
histogram;
by Opioid_or_Benzo Group_Indicator;
run;
/* Checking 1-fill patients */
proc sql;
create table one_fill_patients
as select distinct a.*
from data3.analytic_file as a inner join count_sums as b
on a.MRN = b.MRN
where fill_refill_count = 1 /* Eliminates patients included in error */
;
quit;
%mend;
... View more
07-22-2020
12:43 PM
1 Like
Oh, yeah you're actually right. My thought process was, if we match Case + Group2, doesn't it ignore all information from Group 1? That's what I was kind of hung-up on. I was just wondering if there was any way to do a "3-way" match because even googling for it didn't give me very great answers.
I also was thinking that perhaps I would have different weights in the 2 data sets but I just checked and all the weights in the "case" group are just 1. Your suggestion makes much more sense now. Thanks.
... View more
07-22-2020
06:26 AM
Thanks for the links Reeza, but I think my issue is how do I deal with the 3rd group? My 3 groups could basically be labeled as 0,1, and 2. PSmatch only lets me match on a binary variable. This is the part I'm struggling with. Like ideally I could run psmatch on all 3 groups and then run proc GLM. I've been unable to find how you can do this in SAS.
... View more
07-21-2020
05:08 PM
So this may be more of a "stat" question than a SAS question but I have never learned the process of matching in school. Regression was what was ingrained in me and that was the method to use when it came to dealing with confounders. However, in the industry I'm currently working in, they match patients and since this is what's more commonly used I was told to try to do matching for a project.
My issue is, I don't understand how exactly psmatch works and if it is possible to do a proc ANOVA using the results of psmatch. All the examples I looked at, they ran a ttest using the output file from psmatch. I however, needed to try to compare 3 groups, and only matched the control group with the treated group due to psmatch not working with 3 groups, the 3rd group is also kind of a control but not exactly. I am trying to match using propensity score weighting. I understand that this data can spit out a ATTWGT variable that is basically the "Weight" for each subject. I know that if I were to just compare 2 groups I could specify the weight statement in a proc ttest. I was wondering if there was a way to do this with proc ANOVA. If not, using matchid also doesn't work because this was based on weights and not exact matching. I was told that matching basically just would pair patients up that had similar features(Based on what we matched on) and when I run a statistical test, I just use the matched pair and throw out the unmatched data.
I guess I'm just not understanding what exactly psmatch does and what I'm supposed to do after running psmatch. Any help would be appreciated, thanks.
... View more
08-08-2018
03:37 PM
Thanks, this worked and basically answered what I was looking for.
... View more
08-08-2018
03:34 PM
Your method would definitely create some issues, but basically if you need additional information...(I didn't think it would be needed because my question seems pretty simple). I was basically running proc mixed, generating residuals for each variable, and testing for normality using the ODS output "TestsForNormality." Since I have ~800 variables/simple models to run I wanted to stack these tables all together. The problem I ran into was... some of these didn't exist because there was a lack of variation. Hence why I had this question. I tried to stack 800+ files together, had errors thrown saying some files were missing, SAS wouldn't generate the table with them all stacked together.
... View more
08-08-2018
02:48 PM
So this is a general question about how SAS works. Basically if I am trying to stack a bunch of files together but there are some that are missing why does SAS throw an error and not proceed with the command? For example data CombinedA;
set A1-A900;
run;
Let's say you were missing some files in there like... A89, A401, A589, A623, etc...
SAS will throw an error saying those files don't exist but the "CombinedA" file also does not get created.
Is there a way to bypass this issue so that SAS will still stack all existing files together? I understand that yes I could just type in ranges and skip over the missing files but that can become tedious.
... View more
01-02-2018
04:54 PM
So I used this link https://blogs.sas.com/content/iml/2013/02/27/slope-of-a-regression-line.html and had a further quesiton about it. Is there a way to get the slope coefficient for each group separately?
I used this code to generate the model and found a significant interaction effect. I wanted to generate some plots for these significant ones.
proc mixed data=&data namelen = 200; class &group; model &response = &exposure &group &exposure*group + confounders; ods output tests3 = Fulltest&i; run;
I have this code to try and generate the graphs:
ods graphics off; proc reg data=&data; model &response = &alcoholvar; ods output ParameterEstimates=PE; run;
data _null_; set PE; if _n_ = 1 then call symput('Int', put(estimate, BEST6.)); else call symput('Slope', put(estimate, BEST6.)); run;
PROC sGPLOT DATA = &data (where =( &group ne .)) noautolegend dattrmap = attrmap ; reg x = &x y = &y /group = &group clm clmtransparency = 0.4 attrid = &group; title "&title"; inset "Intercept = &Int" "Slope = &Slope" / border title="Parameter Estimates" position=topleft; run;
This only generates the intercept and slope for the first group listed. Is there any way to generate the slope for each group, (in my case there are 3 groups)? So there should be a slope for the line with group = 0, an 2nd slope for the line with group = 1, and a 3rd slope for the line with group = 2.
... View more
07-24-2017
04:00 PM
This is kind of related to an earlier question I had because I'm sure some of you contributors saw it. Basically I am generating a box chart and a regression plot but I want to keep the colors consistent. I am generating a lot of them and I noticed on some graphs the color would be reversed aka in the box chart red = 0, blue = 1, while in the regression plot red = 1 and blue = 0. I tried to make an ATTRMAP file but for some reason this made some of the regression colors GREEN instead of blue and I don't understand why, while in the bar chart nothing really changed.
%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue "; output;
Value = '1'; MarkerColor = "Red "; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;
In the part of the macro, the issue occured with certain SNPs that I ran this through. Some of the graphs looked fine (aka consistent color between the bar chart and regression plot), but as mentioned before some of the "blue" lines turned "Green". Before I added in the dattrmap statement I had an issue with inconsistent colors.
... View more
07-21-2017
11:49 AM
The thing was... my log wasn't showing anything like I mentioned my SAS just "hung" there. The syntax error didn't show up unless I was trying to close my SAS application....
... View more
07-21-2017
11:34 AM
OMG, I figured out the issue, I was missing a ")" at the end of my macro calling.
... View more
07-21-2017
11:09 AM
@Rick_SAS The code you posted did work.... I don't know what SAS is doing but trying to use the plots macro like this DOESN'T work. %plots(data2.inputdataremoved, choline_f2a, WRPM_ss, snp180, rs8016556_C(FDR=0.0403323974); although If i replace the macro variables with these exact names it works outside the macro....
... View more
07-21-2017
09:18 AM
@Quentin Yeah... it's like trying to run the macro "plots" breaks my SAS because I don't get anything from proc print data = sashelp.class Everything will work before I try to create the plots macro. For any code before this step, the only thing I did was reference the libraries. As for my SAS client I'm not exactly sure because the name of the program is literally just "SAS for Window". SAS 9.4 TS Level 1M3. Also @ballard yes I know they aren't exactly the same thing but I meant even if I used the same "X" and "Y" SAS just isn't cooperating with the "plots" macro I generate. Oh also an additional detail seems like the Error(upon closing SAS) that I get says... "ERROR: Macro parameter contains syntax error"
... View more