SAS Viya Copilot for Code Assistance in SAS Data and AI Studio
Recent Library Articles
In this post, we’ll take a look at how SAS Viya Copilot for Code Assistance can help with some of those everyday tasks: understanding code, improving it, and making changes more confidently—all without leaving the SAS Data and AI Studio environment.
SAS Forward: Real Stories, Live Demos and AI Innovation
Ask the Expert
Join us November 4-5 for SAS Forward, a virtual event exploring modern analytics, AI and intelligent decisioning. Discover real-world success stories, explore emerging trends, and see the latest SAS innovations in action through expert-led sessions and live demonstrations.
SAS Enterprise Guide 8.3 is not displaying all Oracle library tables in the Server List. The library appears with a 'Browse' node instead of fully expanding, even after increasing MaxObjectsToDisplay in SEGuide.exe.config .
... View more
What game scenarios (e.g., dice, card games, roulette, or lotteries) do you use to demonstrate probability, distributions, or modeling in SAS? Has anyone tried creating game simulations to train machine learning models? I think games of chance are a good metaphor for teaching statistics and data analysis.
... View more
Hi All, I have some data from an examination that has 92 multiple choice questions that have very unique names/ids. I wrote the following SAS code. The code is giving me the following errors and I don't know why. Can someone please help me by debugging the code? ERROR: File WORK._CMH_STAT.DATA does not exist. ERROR: File WORK._MH_OR.DATA does not exist. /* ========================================================================= */ /* INSERTION: Mantel-Haenzel DIF Testing */ /* ========================================================================= */ %macro mh_dif_rank_purification( indata=, /* Input dataset containing items, Group, and ID */ group=, /* Focal vs Reference variable (0=Reference, 1=Focal) */ id=, /* Unique student identifier */ out_summary= /* Output dataset name for final test statistics */ ); /* STEP 1: Dynamically extract all item names from your dataset */ proc contents data=&indata(drop=&group &id) out=_metadata(keep=name) noprint; run; proc sql noprint; select name into :item_list separated by ' ' from _metadata; select count(name) into :num_items from _metadata; quit; %put NOTE: Found &num_items items to evaluate: &item_list; /* STEP 2: STAGE 1 - Calculate initial unpurified total raw scores */ data _stage1_scored; set &indata; total_score_init = sum(of &item_list); run; /* Create macro arrays to store individual item statistics loops */ %do i = 1 %to &num_items; %let item = %scan(&item_list, &i, %str( )); /* Stratify by matching criterion excluding the item under evaluation */ data _temp_strat; set _stage1_scored; matching_score = total_score_init - &item; run; /* Extract MH Common Odds Ratio and CMH Chi-Square */ ods listing close; ods output CMH=_cmh_stat(where=(Statistic=3)) CommonOddsRatioCL=_mh_or(where=(Method="Mantel-Haenszel")); proc freq data=_temp_strat; tables matching_score * &group * &item / cmh cmh(mh); run; ods listing; /* Merge stats for this item */ data _item_res_&i; merge _cmh_stat(keep=Prob rename=(Prob=p_value)) _mh_or(keep=Value LowerCL UpperCL rename=(Value=Alpha_MH)); length Item_Name $32; Item_Name = "&item"; run; %end; /* Combine all Stage 1 results */ data _stage1_all; set _item_res_1 - _item_res_&num_items; run; /* Identify flagged items using alpha = 0.05 for Stage 1 Purification */ proc sql noprint; select Item_Name into :flagged_items separated by ' ' from _stage1_all where p_value < 0.05; quit; %put NOTE: Flagged items for exclusion from final matching score: &flagged_items; /* STEP 3: STAGE 2 - Purified Analysis with 5-Strata Ranking */ data _stage2_scored; set &indata; /* Calculate a purified total score excluding flagged items */ total_score_purified = sum(of &item_list) - sum(of &flagged_items); run; /* Execute the final stratified MH Analysis using Ranked Quintiles */ %do i = 1 %to &num_items; %let item = %scan(&item_list, &i, %str( )); data _final_prep; set _stage2_scored; /* Recalculate final criterion conditioning out the item if it was clean */ %if %sysfunc(indexw(&flagged_items, &item)) > 0 %then %do; final_matching_score = total_score_purified; %end; %else %do; final_matching_score = total_score_purified - &item; %end; run; /* Use PROC RANK to divide the continuous matching score into 5 strata (0 to 4) */ proc rank data=_final_prep out=_final_strat groups=5 noprint; var final_matching_score; ranks matching_strata; run; ods listing close; ods output CMH=_final_cmh(where=(Statistic=3)) CommonOddsRatioCL=_final_or(where=(Method="Mantel-Haenszel")); proc freq data=_final_strat; /* Using the stratification variable instead of the continuous score */ tables matching_strata * &group * &item / cmh cmh(mh); run; ods listing; data _final_res_&i; merge _final_cmh(keep=Value Prob rename=(Value=CMH_ChiSq Prob=p_value)) _final_or(keep=Value LowerCL UpperCL rename=(Value=Alpha_MH)); length Item_Name $32; Item_Name = "&item"; run; %end; /* STEP 4: Combine, calculate Delta MH, and apply ETS classification rules */ data &out_summary; set _final_res_1 - _final_res_&num_items; /* 1. Calculate Delta MH */ if Alpha_MH > 0 then Delta_MH = -2.35 * log(Alpha_MH); else Delta_MH = .; /* 2. Apply ETS Category Classifications (A, +B, -B, +C, -C) */ /* Category A: Negligible DIF */ if abs(Delta_MH) < 1.0 or p_value >= 0.05 then ETS_Category = "A "; /* Category C: Large DIF */ else if abs(Delta_MH) >= 1.5 and (abs(LowerCL) > 1.0 or abs(UpperCL) > 1.0) then do; if Delta_MH > 0 then ETS_Category = "+C"; else ETS_Category = "-C"; end; /* Category B: Moderate DIF */ else do; if Delta_MH > 0 then ETS_Category = "+B"; else ETS_Category = "-B"; end; label Item_Name = "Item Identifier" CMH_ChiSq = "Cochran-Mantel-Haenszel ChiSquare" p_value = "MH Significance (p-value)" Alpha_MH = "Mantel-Haenszel Common Odds Ratio" Delta_MH = "ETS Delta MH statistic" ETS_Category = "ETS DIF Classification Category"; run; /* Clean up temporary workspace data structures */ proc datasets lib=work nolist; delete _metadata _stage1_scored _stage2_scored _cmh_stat _mh_or _final_cmh _final_or _stage1_all _temp_strat _final_prep _final_strat _item_res_1 - _item_res_&num_items _final_res_1 - _final_res_&num_items; quit; %put NOTE: MH DIF Complete with 5-strata ranking. Final dataset: &out_summary; %mend mh_dif_rank_purification; /* Call the macro with your specific data configurations */ %mh_dif_rank_purification( indata = equate.stacked_data, /* 1. Name of your input SAS dataset */ group = Year, /* 2. Name of your group variable (e.g., Gender, Ethnicity) */ id = id, /* 3. Name of your unique student ID variable */ out_summary = equate.final_dif_stats /* 4. Name you want for your single output dataset */ ); Thanks and Regards, pristine17.
... View more
Hello We are running SAS 9.4M9 on Windows Server on VMWare in the on-prem data center. Exploring the possibility of moving over them to AWS. One option that comes to mind is why not lift and shift to AWS. Wondering if some one has tried this approach and its pros and cons. I do understand that once it is moved to AWS there may be many configuration changes needed. Thanks.
... View more
Good day
I have a data set with multiple parameters each parameter with its own specification that I want to reflect on a report using proc report. Other parameter has only ONE specification whilst others have a range between two extremes. How do I show the specifications for the parameters in a data set for reporting using proc report? The code I used is as below:
proc format; value $LessThan "LE" = "(*ESC*){unicode 2264}";
value $GreaterThan "GE" = "(*ESC*){unicode 2265}"; run;
%Let Spec_Determ1 = 10; %Let Lower_Spec_Determ2 = 15; %Let Upper_Spec_Determ2 = 25;
Data dataset2; set challenge; format Specification $40.; if Determ = 'Determ1' then do;Specification =catx(" ",put("LE", $LessThan.),&Spec_Determ1); end; else if Determ = 'Determ2' then do;Specification =catx(" ",put("GE", $GreaterThan.),&Lower_Spec_Determ2,'to',put("LE",$LessThan.),&Upper_Spec_Determ2); end; run;
proc report datadata=dataset2; columns Determ Specification Result; run;
... View more