Good day,
How do i write a sas code that wiill;
1. Utilize a total i obtained for a variable(such as nF=total number of females in a gender column) via proc mean in the dataset i want to create follwoing that command?
2. sum of squares for negative differences of females that may extend from i=1 to nF?
1. Store results in a table and merge the tables. Or still store it in a table, create a macro variable with the information and use that in future steps.
2. Your requirements are unclear. Proc Means does some differences or errors. Check all the statistics available in the documentation.
Re your second response i will try to clarify my question. Kindly find attached the simplified version of what i want to ask.
Hi,
I do not know if this what you are looking for (based on the istructions in the notebook - picture, it is counting status M) :
DATA TEST;
INPUT MARITAL_STATUS $ INITIAL_BP FINAL_BP;
DATALINES;
M 60 70
S 80 60
C 90 70
C 100 60
M 120 80
S 141 90
S 80 120
S 90 110
S 115 110
M 117 112
C 114 112
C 105 96
M 103 87
M 107 110
S 106 110
;
PROC SQL ;
SELECT COUNT(*) INTO :NS FROM TEST WHERE MARITAL_STATUS='S';
SELECT COUNT(*) INTO :NNS FROM TEST WHERE MARITAL_STATUS='S' & SUM(INITIAL_BP,-FINAL_BP)<0 ;
QUIT;
%PUT SINGLES &NS. ; /*can be omitted*/
%PUT SINGLES NEGATIVE &NNS. ; /*can be omitted*/
DATA TEST;
SET TEST;
IF SUM(INITIAL_BP,-FINAL_BP)<0 & MARITAL_STATUS='S' THEN
JIF=(INITIAL_BP**2/SUM(INITIAL_BP,-FINAL_BP)**3)/(&NS.*&NNS.);
RUN;
PROC PRINT DATA=TEST;
RUN;
PROC MEANS DATA=TEST N SUM;
VAR JIF;
RUN;
M | 60 | 70 | . |
S | 80 | 60 | . |
C | 90 | 70 | . |
C | 100 | 60 | . |
M | 120 | 80 | . |
S | 141 | 90 | . |
S | 80 | 120 | -0.00556 |
S | 90 | 110 | -0.05625 |
S | 115 | 110 | . |
M | 117 | 112 | . |
C | 114 | 112 | . |
C | 105 | 96 | . |
M | 103 | 87 | . |
M | 107 | 110 | . |
S | 106 | 110 | -9.75347 |
3 | -9.8152778 |
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.