BookmarkSubscribeRSS Feed
Karina77
Calcite | Level 5

Hello:

Please advise.  I need to create a new variable "Missing"  that only contains the sum of the missing values.  Thank you

data psych;

  input ID $3. Ques1-Ques10 Score1-Score5;

  ARRAY new (10)RQues1-RQues10;

  ARRAY old (10) Ques1-Ques10;

  DO i = 1 to 10;

  new :smileyinfo: =  6 - old (i);

  END;

  ToTQues = SUM(OF Ques1 -Ques10);

datalines;

001 1 3 2 4 5 4 3 4 5 4 90 88 92 95 90

002 3 3 . . 3 4 5 5 1 . 64 64 77 72 71

003 . . . . 5 5 4 4 3 3 68 69 80 75 70

004 5 3 4 5 . 5 4 3 3 . 88 77 66 77 67

005 5 4 3 2 1 1 2 3 4 5 92 93 94 95 99

006 4 5 1 3 2 5 3 1 1 1 55 65 71 85 91

007 3 2 2 1 5 4 5 3 2 2 60 70 88 79 82

008 2 1 1 5 5 4 4 2 1 3 65 87 90 60 55

009 1 1 1 3 2 2 3 5 4 4 71 81 91 77 88

010 2 3 3 4 1 5 2 2 3 1 64 69 61 70 70

;

proc print data = psych;

run;

3 REPLIES 3
LinusH
Tourmaline | Level 20

Sum of missing is...missing....?

Please give some sample desired output data.

Data never sleeps
KachiM
Rhodochrosite | Level 12

Do you want the count of missing values of Ques1 - Ques10? If so, then try this:

data psych;

  input ID $3. Ques1-Ques10 Score1-Score5;

Tot_Miss = nmiss(of Ques:);

datalines;

001 1 3 2 4 5 4 3 4 5 4 90 88 92 95 90

002 3 3 . . 3 4 5 5 1 . 64 64 77 72 71

003 . . . . 5 5 4 4 3 3 68 69 80 75 70

004 5 3 4 5 . 5 4 3 3 . 88 77 66 77 67

005 5 4 3 2 1 1 2 3 4 5 92 93 94 95 99

006 4 5 1 3 2 5 3 1 1 1 55 65 71 85 91

007 3 2 2 1 5 4 5 3 2 2 60 70 88 79 82

008 2 1 1 5 5 4 4 2 1 3 65 87 90 60 55

009 1 1 1 3 2 2 3 5 4 4 71 81 91 77 88

010 2 3 3 4 1 5 2 2 3 1 64 69 61 70 70

;

run;

Karina77
Calcite | Level 5

that worked!  thank you

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 416 views
  • 3 likes
  • 3 in conversation