Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:41:27+00:00 2026-06-05T17:41:27+00:00

Could you help to calculate the number of each variable where each variable =1?

  • 0

Could you help to calculate the number of each variable where each variable =1? I posted how can I calculate the missing number here. Hopefully, it is the similar way. Thanks in advance.

/*y00*/
%let list0=OCALZHMR OCARTERY OCARTH  OCCHD OCDIABTS OCHBP OCMENTAL OCMYOCAR
          OCOTHART OCPSYCH OCSTROKE;

/*y01 and y02*/
%let list1=D_CFAIL D_CHD D_HBP D_MYOCAR D_OTHHRT  D_PSYCH D_RHYTHM D_STROKE 
       D_VALVE OCALZHMR OCARTERY OCARTH  OCCHD OCDIABTS OCHBP OCMENTAL OCMYOCAR 
       OCOTHART  OCPSYCH OCSTROKE;


proc means data=cohort00 nmiss noprint;
     var &list0; 
     output out=y2000_nmiss(drop=_:) nmiss= ;
run;

proc means data=cohort01 nmiss noprint;
     var &list1; 
     output out=y2001_nmiss(drop=_:) nmiss= ;
run;

data y2000_nmiss;
 set y2000_nmiss;
 j=1;
run;

data y2001_nmiss;
 set y2001_nmiss;
 j=1;
run;

proc transpose data=y2000_nmiss out=long0(rename=(COL1=Y2000 _name_=VAR));
     by j;
run;
proc transpose data=y2001_nmiss out=long1(rename=(COL1=Y2001 _name_=VAR));
     by j;
run;

data ATC_missing;
  merge long0 long1;
  by VAR;
  drop j;
run;

Here is the part of output table for the number of missing :

   VARS  Y2000   Y2001  Y2002
OCDIABTS    0     1        0
OCHBP       0     0        0
OCMENTAL   17    18       10
OCMYOCAR    0     0        0
OCOTHART    0     0     4758
OCOTHHRT    .     .        .
OCPSYCH     0     0        0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:41:29+00:00Added an answer on June 5, 2026 at 5:41 pm
    %let list1=Width Length Depth;
    
    data work.is_even / view=work.is_even;
    set sashelp.lake;
       array vars {*} &list1 ;
       drop i;
       do i=1 to dim(vars);
           if mod(round(vars(i), 1),2)  = 0 /* would be VARS(I)=1 for your case */
            then vars(i)=1;
       else vars(i)=.;
       end;
    run;
    
    proc means data=work.is_even n;
    run;
    

    First I create a datastep view work.is_even (view in order to avoid a full copy of data) that manipulates the data in the way I need.
    Here it overrides the original value of variables (not in original data, just in that view) by 1 if the rounded value is even, by null if it’s odd.
    Then, just count the nonmissing values (N statistic in PROC MEANS).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My first post here – hoping you can help me with designing an algorithm
I would be grateful if someone could help me out here. I'm just starting
What could help me in helping writing highly compact(least byte code count) programs in
I was hoping someone could help me with the following script: jQuery(document).ready(function($) { $(.infoBoxBtn
I hope you could help me. I' m using QT and try to do
was hoping you could help me out. I am trying to check if a
I was hoping someone could help me with submitting the answers to an HTML
Wondering if someone could help me. I have next to no knowledge with Ajax,
Hope someone could help me with this: I would like to have a column
I wonder if someone could help me figure out how to parse a string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.