I am currently analyzing the impact of an intervention on medication numbers using difference-in-difference analysis, but I have encountered several challenges. Following the SAS support instructions, I conducted the difference-in-difference analysis. However, I noticed a discrepancy between my results and SAS's example (Usage Note 61830: Estimating the difference in differences of means). In the example, the value of 'Mean Estimate' in 'Contrast Estimate Results' is identical to the 'Estimate' in 'Least Squares Means Estimate'. However, in my case, these values were different. I suspect this could be due to my use of the negative binomial distribution with a log link, resulting in exponential values. Consequently, I am unsure whether to rely on the 'Mean Estimate' in 'Contrast Estimate Results' or the 'Estimate' in 'Least Squares Means Estimate', and how to interpret the results." Contrast Estimate Results Label Mean Estimate Mean Confidence Limits L'Beta Estimate Standard Error diff in diff 1.51 1.49 0.41 0.0051 a*b Least Squares Means a b Estimate Standard Error z value Pr > |z| 1 1 0.77 0.00434 178.19 <.0001 1 0 0.03 0.00508 6.5 <.0001 0 1 0.72 0.00408 177.71 <.0001 0 0 0.40 0.00426 93.11 <.0001 Least Squares Means Estimate Effect Label Estimation Standard Error z value Pr > |z| time*hospitalize diff in diff 0.41 0.00509 81.01 <.0001
... View more
Hi, I'm currently merging multiple datasets and consistently using the following SQL code to verify there are no duplicate IDs at each stage of the process: proc sql; select count(distinct ID) as UniqueIDs, count(*) as NObs from dataset; quit; This approach effectively identifies duplicates when datasets have multiple timepoints, and I make sure to only select one timepoint per ID. Throughout the merging process, my checks confirm that all IDs remain unique (e.g., 1500 observations and 1500 unique IDs). However, after the final merge, the same SQL query unexpectedly shows 1500 observations but only 1300 unique IDs. Manual verification confirms that duplicates are present, despite prior checks showing no such issues. I'm looking for insights into why these duplicates weren’t detected sooner by the SQL query, or if there's a specific merging condition I might have overlooked. Edited to add: The SQL code above is the one that I use to check each dataset for duplicates (which it seems to find pretty well) and after each merge. Merge code (throughout and also the last one): data merged_dataset; merge dataset1 dataset2; by ID; run; Attaching the LOG for the last merge + SQL check. The result for this was 1181 UniqueIDs and 1229 NObs, while previously I was getting 1229 UniqueIDs and 1229 NObs. LOG for the last merge + SQL check
... View more
Hi, Can anybody help me with formatting the datetime correctly in my program? I am mostly getting blank columns or getting the date as 01Jan1960:9:25:00 Etc. Here's the code I am using data x; set x; y_new = input(y, andtdtm.); format y_new datetime22.; run; And here's how some values in the datetime column look like when imported into SAS: 45348.3506829051 45349.8328009028 45350.7706134028 Thank you! Best regards, Abhishek
... View more
Suppose to have the following:
data DB;
input ID :$20. Discharge :date9.;
format Discharge date9.;
cards;
0001 19JUN2017
0001 07SEP2020
0002 17MAR2016
0003 05MAY2016
0003 08FEB2017
0004 22MAR2017
0004 03MAY2017
0004 28MAR2021
;
data DB1;
input ID :$20. Discharge :date9. Combined;
format Discharge date9.;
cards;
0001 19JUN2017 0001_19JUN2017_1
0001 07SEP2020 0001_07SEP2020_2
0002 17MAR2016 0002_17MAR2016_1
0003 05MAY2016 0003_05MAY2016_1
0003 08FEB2017 0003_08FEB2017_2
0004 22MAR2017 0004_22MAR2017_1
0004 03MAY2017 0004_03MAY2017_2
0004 28MAR2021 0004_28MAR2021_3
;
Is there a way to combine IDs and dates in a new variable and add an incremental number (after sorting by ID and Discharge) as suffix?
Desired output: DB1
Thank you in advance
... View more
Hi, I have a fiction dataset that I've created like this data countries;
length country $20 country_1 $50;
input country $ country_1 $;
datalines;
AE United Arab Emirates
AR Argentina
AU Australia
Africa Africa
Asia Asia
CA Canada
CH Schweiz
CN China
DE Germany
ET Etiopia
EU Europe
FR France
GB United Kingdom
GM Gambia
KR Republic of Korea
KZ Kazakstan
Latin_America_31 Latin America-31
Middle_East Middle East
NO Norway
NP Nepal
NZ New Zealand
Non_EU_Europe Non-EU Europe
PE Peru
PH Philippines
RU Russia
TR Turkey
UA Ukraine
World World
;
run;
data countries_extended;
set countries;
do i = 1 to ceil(ranuni(0) * 100); /* Upprepa varje land slumpmässigt upp till 100 gånger */
output;
end;
drop i;
run; and I have SAS 9.4 - which mean it can't take union all, and such. How do I create a variable a variable hierarchy, beacuse now it is mixed in col=country. I've read that you can self join in this case, but the output was bad.. Which I tried to do, but it didn't went well. Can someone please help me out?
... View more