awesome_opossum Tracker
https://communities.sas.com/kntur85557/tracker
awesome_opossum TrackerWed, 24 Apr 2024 08:53:32 GMT2024-04-24T08:53:32ZRe: Minimal detectable change and test-rest variability
https://communities.sas.com/t5/Statistical-Procedures/Minimal-detectable-change-and-test-rest-variability/m-p/897397#M44467
<P>It's been awhile since I've done a model like this. You have the first step correct, or at least workable. You need add predictors to your y = model, and it may also be necessary to add random slopes for your "boxes", depending on model fit. </P>Thu, 05 Oct 2023 13:40:18 GMThttps://communities.sas.com/t5/Statistical-Procedures/Minimal-detectable-change-and-test-rest-variability/m-p/897397#M44467awesome_opossum2023-10-05T13:40:18ZRe: proc sql using or
https://communities.sas.com/t5/SAS-Procedures/proc-sql-using-or/m-p/897396#M82972
Principally speaking though, proc sql is multi-threaded, so you can also ramp up your processors. SAS uses 4 by default, but if your computer/server is faster, you can increase it. However, not all SAS procs are multi-threaded, just SQL happens to be one.Thu, 05 Oct 2023 13:33:43 GMThttps://communities.sas.com/t5/SAS-Procedures/proc-sql-using-or/m-p/897396#M82972awesome_opossum2023-10-05T13:33:43ZRe: Adjusted frequency : proc logistic
https://communities.sas.com/t5/Statistical-Procedures/Adjusted-frequency-proc-logistic/m-p/896281#M44423
<P>Ah, you're overthinking it. </P>
<P> </P>
<P>Just take your code, choose a predictor of interest, PREDICTOR1, remove it as a predictor in the equation, and rerun the model with</P>
<P>WHERE PREDICTOR1 = 1;</P>
<P> </P>
<P> </P>Thu, 28 Sep 2023 16:00:49 GMThttps://communities.sas.com/t5/Statistical-Procedures/Adjusted-frequency-proc-logistic/m-p/896281#M44423awesome_opossum2023-09-28T16:00:49ZRe: Adjusted frequency : proc logistic
https://communities.sas.com/t5/Statistical-Procedures/Adjusted-frequency-proc-logistic/m-p/896254#M44417
<P>I think that's a substantively different question, and for that you need discriminant function analysis. </P>
<P> </P>
<P>However, I would also say, there's not really any benefit to doing discriminant function analysis over logistic regression. Logistic regression is easier to understand, and the information is essentially mathematically identical. </P>Thu, 28 Sep 2023 14:09:40 GMThttps://communities.sas.com/t5/Statistical-Procedures/Adjusted-frequency-proc-logistic/m-p/896254#M44417awesome_opossum2023-09-28T14:09:40ZRe: Is there more than one form of comment (e.g. /*) that can be used?
https://communities.sas.com/t5/SAS-Programming/Is-there-more-than-one-form-of-comment-e-g-that-can-be-used/m-p/891104#M352079
<P>All really great answers! Thank you so much!</P>
<P> </P>
<P>Is there no close topic option unless you signify an answer? Wow. </P>
<P> </P>
<P>I guess we'll work that one out tomorrow. </P>Fri, 25 Aug 2023 18:41:11 GMThttps://communities.sas.com/t5/SAS-Programming/Is-there-more-than-one-form-of-comment-e-g-that-can-be-used/m-p/891104#M352079awesome_opossum2023-08-25T18:41:11ZIs there more than one form of comment (e.g. /*) that can be used?
https://communities.sas.com/t5/SAS-Programming/Is-there-more-than-one-form-of-comment-e-g-that-can-be-used/m-p/891008#M352062
<P>So I'm really thinking about this in how to adapt someone else's code. </P>
<P> </P>
<P>The problem is there are both substantive comments, as in explanations, as well as code that is commented out. Therefore I cannot do a global ctrl+shift+?, because the substantive/explanation comments would also be released into the program, faltering a full run. </P>
<P> </P>
<P>Is the only option actually to go through each step and comment/uncomment as needed, rather than being able to observe the data/print that goes along with each analytic step in the full run? I understand even with a full run, there may or may not be issues around recursive table naming, etc, but I am not concerned about that in this case. </P>
<P> </P>
<P>It would be useful if there is two forms of comment, one for code and one for substantive comments? </P>Fri, 25 Aug 2023 14:54:03 GMThttps://communities.sas.com/t5/SAS-Programming/Is-there-more-than-one-form-of-comment-e-g-that-can-be-used/m-p/891008#M352062awesome_opossum2023-08-25T14:54:03ZRe: Create dummy variable if date is any US federal holiday
https://communities.sas.com/t5/SAS-Programming/Create-dummy-variable-if-date-is-any-US-federal-holiday/m-p/889731#M351551
<P>Sorry to say, I don't have an answer for you. It's an interesting question analytically, but how could you possibly control for the fact that different holidays mean different things to different people? </P>Thu, 17 Aug 2023 19:23:38 GMThttps://communities.sas.com/t5/SAS-Programming/Create-dummy-variable-if-date-is-any-US-federal-holiday/m-p/889731#M351551awesome_opossum2023-08-17T19:23:38ZRe: Help needed to find alternatives for joins
https://communities.sas.com/t5/SAS-Programming/Help-needed-to-find-alternatives-for-joins/m-p/886834#M350411
<P>If you mean computing performance, something you might consider is that proc sql allows for multi-threaded processing. SAS defaults to 4 processors, but if your computer/system has more processors, you can increase that number. </P>
<P> </P>
<PRE><CODE class=" language-sas">/* evaluate CPU usage default for new session / since last CPU setting during session */
proc options option=cpucount;
run; /* default CPU count = 4 */
/* count and use all CPUs available for multi-threaded procs */
options threads cpucount=actual;
proc options option=cpucount;
run; /* count and use max CPU count available; my comp = 20 */
/* set CPUs count to use manually for multi-threaded procs */
options threads cpucount=19;
proc options option=cpucount;
run; /* max CPU count (20) - 1 = 19 (as not to overload other programs/processing) */ </CODE></PRE>
<P> </P>
<P> </P>Fri, 28 Jul 2023 16:22:57 GMThttps://communities.sas.com/t5/SAS-Programming/Help-needed-to-find-alternatives-for-joins/m-p/886834#M350411awesome_opossum2023-07-28T16:22:57ZRe: Proc Format
https://communities.sas.com/t5/Statistical-Procedures/Proc-Format/m-p/883322#M43711
<P>Reeze are you studying sleep probs again? You're going to make a helpful accident, which you do every time!</P>Mon, 03 Jul 2023 13:17:08 GMThttps://communities.sas.com/t5/Statistical-Procedures/Proc-Format/m-p/883322#M43711awesome_opossum2023-07-03T13:17:08ZRe: Proc Format
https://communities.sas.com/t5/Statistical-Procedures/Proc-Format/m-p/882680#M43660
<P>I think it would work if you apply the format in a data step instead of inside proc freq. The format inside proc freq, I think, would only be held within that running of the procedure. Doing it in a data step will apply the format "permanently" (i.e. in subsequent analytic steps, like proc freq). </P>
<P> </P>
<PRE><CODE class=" language-sas">data work.val; set work.val;
format sleepvar fmt.;
run;</CODE></PRE>
<P> </P>Tue, 27 Jun 2023 19:07:03 GMThttps://communities.sas.com/t5/Statistical-Procedures/Proc-Format/m-p/882680#M43660awesome_opossum2023-06-27T19:07:03Zarray to count and set missing values in one step vs. multiple steps
https://communities.sas.com/t5/SAS-Programming/array-to-count-and-set-missing-values-in-one-step-vs-multiple/m-p/877116#M346507
<P>I am trying to count the number of missing values on a set of vars. Then, if there are two or more vars with missing values, I want to set all the vars to have missing values. The following works: </P>
<P> </P>
<PRE><CODE class=" language-sas">data want (drop = i j k); set have;
ct_pre = 0;
ct_post = 0;
array vars (7) var1-var7;
do i = 1 to 7;
if vars{i} = . then ct_pre +1;
end;
do j = 1 to 7;
if ct_pre >= 2 then vars{j} = .;
end;
do k = 1 to 7;
if vars{k} = . then ct_post +1;
end;
run; </CODE></PRE>
<P>Thus I end up with ct_post having only values 0, 1, or 7, as desired. </P>
<P> </P>
<P>However, I can't wrap my head around why this other, seemingly simpler approach doesn't work. Some variables do get set to missing in some cases, but other times they do not get set to missing. Thus, as in ct_pre, ct_post ends up with values 0-7, although a handful of the cases change in value. There does not appear to be a method to the madness, as in I don't see any strange patterns with specific vars. What does it have to do--I assume--with operating within only a single do/end space? I feel like I'm not understanding something fundamental, so if anyone can explain, I would appreciate it! Thanks!</P>
<P> </P>
<PRE><CODE class=" language-sas">data want (drop = i); set have;
ct_pre = 0;
ct_post = 0;
array vars (7) var1-var7;
do i = 1 to 7;
if vars{i} = . then ct_pre +1;
if ct_pre >= 2 then vars{i} = .;
if vars{i} = . then ct_post +1;
end;
run;
</CODE></PRE>Tue, 23 May 2023 16:40:07 GMThttps://communities.sas.com/t5/SAS-Programming/array-to-count-and-set-missing-values-in-one-step-vs-multiple/m-p/877116#M346507awesome_opossum2023-05-23T16:40:07ZRe: SEM Polychoric Transformation and Exploratory Factor Analysis
https://communities.sas.com/t5/Statistical-Procedures/SEM-Polychoric-Transformation-and-Exploratory-Factor-Analysis/m-p/874715#M43270
<P>Indeed, I could see that working. </P>
<P> </P>
<P>Keep in mind you need the priors=smc option in proc factor to make it a factor analysis; otherwise the default is principal component. </P>Tue, 09 May 2023 17:36:46 GMThttps://communities.sas.com/t5/Statistical-Procedures/SEM-Polychoric-Transformation-and-Exploratory-Factor-Analysis/m-p/874715#M43270awesome_opossum2023-05-09T17:36:46ZRe: SEM Polychoric Transformation and Exploratory Factor Analysis
https://communities.sas.com/t5/Statistical-Procedures/SEM-Polychoric-Transformation-and-Exploratory-Factor-Analysis/m-p/874487#M43268
<P>I would not recommend using polychoric correlations in SEM. It's not that it's principally impossible, but the issue is really that it vastly complicates interpretation. Tetrachoric (binary variable) correlations can work, although even then I would encourage some degree of extra caution about interpretation. </P>
<P> </P>
<P>As well, there is limited SEM functionality regarding this in SAS (and pretty much all other statistical software). As far as I know, the only way to do it in SAS to derive poly/tetrachoric correlations out of proc corr, and then use the correlation matrix as input in proc factor. This will allow you to do exploratory factor analysis, although because the input is a correlation matrix, rather than the actual observations, you cannot derive factor scores. </P>
<P> </P>
<P>I believe the same approach can be used in proc calis with lineqs, but I have not tried it myself. Then, you could confirm your factor structure(s) and also enter endogenous and exogenous variables as you please. However and again, that is exactly where the interpretation challenge comes in. Even if you had acceptable fit features on your confirmatory factors, what do the factors <EM>mean, </EM>and are you confident enough in that meaning that it is justifiable to use it as either a predictor or outcome? </P>
<P> </P>
<P>While I understand some people's disdain for using Likert style items as continuous variables, I would argue CFA and SEM are one specific case where the benefits of treating them as continuous greatly and undeniably outweigh the limitations. </P>Mon, 08 May 2023 16:23:27 GMThttps://communities.sas.com/t5/Statistical-Procedures/SEM-Polychoric-Transformation-and-Exploratory-Factor-Analysis/m-p/874487#M43268awesome_opossum2023-05-08T16:23:27ZRe: Proc SurveySelect Proportional
https://communities.sas.com/t5/SAS-Procedures/Proc-SurveySelect-Proportional/m-p/872853#M82694
<P>You may wish to check my work, but I believe you can do it manually as so. The "problem" with surveyselect for your purposes, I believe, is that 1) it uses the natural representation for any strata, whereas you wish to impose weighting/representation (e.g. 50% male/female, x% for groups... you say 10%, but if you're seeking to make them equally represented, as in, with the same rule, as sex, it is actually the number of age groups you are interested in that defines the proportion, as in 10% would be for 10 groups, like 50% is for two sexes), and 2) you also wish to draw only one case per house. </P>
<P> </P>
<PRE><CODE class=" language-sas">
data house;
input id house $ sex $ age;
cards;
1 House1 M 23
2 House1 F 55
3 House2 M 22
4 House2 M 27
5 House3 F 15
6 House3 M 36
7 House3 F 50
8 House3 F 33
9 House3 M 22
10 House3 M 25
11 House3 M 21
12 House4 F 15
13 House4 M 38
14 House5 M 38
15 House5 F 38
16 House6 F 37
;run;
proc sql; create table house2
as select
id,
count(id) as idct,
house,
sex,
count(unique sex) as sexgroupct,
age,
(case when age >= 15 and age < 25 then '15 to 24'
when age >= 25 and age < 35 then '25 to 34'
when age >= 35 then '>=35' end) as agegroup,
count(unique calculated agegroup) as agegroupct
from house
;
quit;
data house3; set house2;
weightgroup = catx('-', sex, agegroup);
run;
proc sql; create table house4
as select
*,
count(weightgroup) as weightgroupct,
(calculated weightgroupct / idct) as weightgroupA,
(1 / sexgroupct) as sexgroupweight,
(1 / agegroupct) as agegroupweight,
(calculated sexgroupweight * calculated agegroupweight) as weightgroupT,
(calculated weightgroupT / calculated weightgroupA) as weight
from house3
group by weightgroup;
quit;
data house5; set house4;
call streaminit(123);
random = rand('Uniform');
randombyweight = (random * weight);
run;
proc sql; create table house6
as select
*
from house5
group by house
having randombyweight = max(randombyweight);
quit; </CODE> </PRE>
<P> </P>Fri, 28 Apr 2023 17:28:22 GMThttps://communities.sas.com/t5/SAS-Procedures/Proc-SurveySelect-Proportional/m-p/872853#M82694awesome_opossum2023-04-28T17:28:22ZRe: Detect inflection point or changing point
https://communities.sas.com/t5/SAS-Programming/Detect-inflection-point-or-changing-point/m-p/872796#M344817
I haven't done it myself in SAS, but it sounds like you might be looking for a spline model. <BR /><BR />SAS has a few ways to do that, I believe, but the only procedure that comes to mind off the top of my head is PROC ADAPTIVEREG. <A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_odsgraph_sect109.htm" target="_blank">https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_odsgraph_sect109.htm</A><BR />Fri, 28 Apr 2023 13:35:48 GMThttps://communities.sas.com/t5/SAS-Programming/Detect-inflection-point-or-changing-point/m-p/872796#M344817awesome_opossum2023-04-28T13:35:48ZProcessor speed vesus multi-threading
https://communities.sas.com/t5/SAS-Procedures/Processor-speed-vesus-multi-threading/m-p/872794#M82693
<P>Hi all, I'm not really sure where to put this because it's kind a broad, maybe somewhat more of a general computer science question than a SAS question per se. Basically I've been charged by my organization to decide what computer system would be best for running some of the notorious hogs such as GLIMMIX. </P>
<P> </P>
<P>In reading, while there's a number of Base and SAS/STAT procedures that permit multi-threading and parallel processing, many do not, such as GLIMMIX, which can only run on a single processor (except perhaps along with some sort of macro--that I do not know even exists or is possible for GLIMMIX, but also I'm not exactly keen on using or getting into macros). </P>
<P> </P>
<P>Thusly I have a sort of two-part assumption: 1) multiple processors lend no advantage to some procs we desire to use, as GLIMMIX, may be helpful for others like SQL, GLM, MIXED and so forth, 2) and this is a gross assumption on my part, a FASTER processor (as in, say 3.60 GHZ vs. 2.8 GHZ), as compared to multiple processors, may be more helpful for use of something that can only run on a single processor, like GLIMMIX. Is this correct? </P>
<P> </P>
<P>More broadly, do you have any other recommendations to maximize computational performance in SAS? I understand, as with processors, it may depend on how SAS itself was written, hence my asking the community here. But again, I'm no computer scientist, so I'm trying to be careful about assumptions. </P>
<P> </P>
<P>Thanks in advance!</P>Fri, 28 Apr 2023 13:27:14 GMThttps://communities.sas.com/t5/SAS-Procedures/Processor-speed-vesus-multi-threading/m-p/872794#M82693awesome_opossum2023-04-28T13:27:14ZRe: Propensity Score Matching Macro %GMATCH Question on 1:2 Match
https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870440#M343797
<P>For analysis, it's essentially a problem of 1) non-independence of observations, and 2) weighting of the multiple control groups in the analysis. Below is assuming all of your matched cases from both control groups (combined) are unique observations--not duplicated. </P>
<P> </P>
<P>The simplest solution, which is probably reasonable acceptable to most people, is likely to simply analyze the two sets of matched pairs separately, and present it as a "replication". If the results are the same for both matched groups, then you can say the same result is achieved with propensity score matching even with an independent control group. If the results are different, it would merit investigation as to whether the difference is due to detectable differences in the matched characteristics of the two control groups (or their difference-in-difference with the study group). Such differences could emerge, and be observed, for example, if a first iteration of the propensity match is a "closer match" than the second iteration of propensity match. </P>
<P> </P>
<P>Partial solutions, which I'm sure would be unsatisfactory to the scientific community (and to me), would be to: a) code the two control groups (e.g. 1 vs. 0) into a variable and enter it as a covariate in a model using all the data, including the double study observations. This would not solve the problem of non-independence, but would more-or-less ensure both control groups are weighted equally and fairly, removing any bias that snuck in from one propensity match iteration to the next. b) Pool or average your responses from the two control groups into a single observation, as to be matched with a single observation of the study group. This resolves the issue of non-independence, and partially ensures the control observations are weighted relatively equally; however, it definitely distorts the underlying true variance of observations in the control groups (which wouldn't necessarily be a problem if you had, say, 20 matched control groups, and could use their observed variance). </P>
<P> </P>
<P>A slightly more complicated solution would be to construct a multilevel model. There, you can enter the study group ID as the identifier for level-2, and the control group ID's as independent observations for level-1. Since you would presumably be predicting level-2 outcomes from level-1 predictors, you could use a simple fixed-effects model (which is relatively simple, nice). This should take care of both your issues of non-independence and comparative weighting of the multiple control groups in a single analysis. Also, as in a) above, you could again code and enter propensity match iteration as a covariate in the model. </P>
<P> </P>
<P> </P>Tue, 18 Apr 2023 20:56:39 GMThttps://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870440#M343797awesome_opossum2023-04-18T20:56:39ZRe: Two-Way Anova on Unequal Proportion data
https://communities.sas.com/t5/SAS-Programming/Two-Way-Anova-on-Unequal-Proportion-data/m-p/860497#M339930
<P>I don't use ANOVA much. But regression is essentially the same; I would just do a logistic account for the binary response. </P>
<P> </P>
<PRE><CODE class=" language-sas">
proc logistic data= data;
class factorA(ref='Silent') factorB(ref='Banana') / param=ref;
model purchase(event='1') = factorA factorB factorA*factorB;
run;
</CODE></PRE>
<P>To get the percentages is a bit more work. You could do some lengthy code to get it, but I would probably just do this, and calculate the differences I wanted manually: </P>
<P> </P>
<PRE><CODE class=" language-sas">proc freq data= data;
tables factorA * purchase;
tables factorB * purchase;
tables factorA * factorB * purchase;
run; </CODE></PRE>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>Thu, 23 Feb 2023 17:14:37 GMThttps://communities.sas.com/t5/SAS-Programming/Two-Way-Anova-on-Unequal-Proportion-data/m-p/860497#M339930awesome_opossum2023-02-23T17:14:37ZRe: complied data
https://communities.sas.com/t5/SAS-Programming/complied-data/m-p/859967#M339738
<PRE><CODE class=" language-sas">proc sql; create table id1
as select
id1,
salary
from data;
quit;
proc sql; create table id2
as select
id2,
salary
from data;
quit;
proc sql; create table wide
as select
a.*,
b.salary as salary2,
(a.salary + b.salary) as total_salary<BR /><BR />/* optionally: ,b.id2 */
from id1 a
left join id2 b
on a.id1 = b.id2;
quit; </CODE></PRE>
<P>There is probably an easier, less wonky way to do this, but here is a step by step approach that should work. This also assumes both ID's are the same format (num/char). </P>Tue, 21 Feb 2023 17:43:34 GMThttps://communities.sas.com/t5/SAS-Programming/complied-data/m-p/859967#M339738awesome_opossum2023-02-21T17:43:34ZRe: Keep unique IDs only
https://communities.sas.com/t5/SAS-Programming/Keep-unique-IDs-only/m-p/859961#M339734
<PRE><CODE class=" language-sas">proc sql; create table data1
as select distinct
*
from data;
quit;
proc sql; create table data2
as select
*,
count(code) as k
from data1
group by id;
quit;
data data3; set data2;
if k = 1;
run; </CODE></PRE>Tue, 21 Feb 2023 17:13:55 GMThttps://communities.sas.com/t5/SAS-Programming/Keep-unique-IDs-only/m-p/859961#M339734awesome_opossum2023-02-21T17:13:55Z