BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rak123
Calcite | Level 5

Hi,

I have used array statement to change the wide format to long format for  a dataset. I created a dataset excluding the missing values of hwt variable. In addition, I want to output the list of subjects missing variable hwt as a separate dataset.

data patient1;

set patrecord;

array cal(i):smileyinfo: hwt1 hwt2 hwt3 hwt4;

do over cal;

   day = i;

  hwt=cal;

IF missing(cal) THEN delete;

output;

end;

keep ID day hwt;

run;

Any suggestions, please!        

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Is something like this what you are looking for?

data patient1

       missinghwt (keep= PatienIdVariable day)

;

set patrecord;

array cal(i) hwt1 hwt2 hwt3 hwt4;

do over cal;

   day = i;

  hwt=cal;

IF missing(cal) THEN output missinghwt;

else output patient1;

end;

keep ID day hwt;

run;

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

A sample of desired output would help. And how do you define "subject".

But it shoulnd't much more than having a second data set defined in the data statement, and have two different output statements (rather than the delete?).

Data never sleeps
art297
Opal | Level 21

I agree with Linus: a sample of the desired output would definitely help.

Do you realize that your current code stops working on a record as soon as it finds a missing value?

ballardw
Super User

Is something like this what you are looking for?

data patient1

       missinghwt (keep= PatienIdVariable day)

;

set patrecord;

array cal(i) hwt1 hwt2 hwt3 hwt4;

do over cal;

   day = i;

  hwt=cal;

IF missing(cal) THEN output missinghwt;

else output patient1;

end;

keep ID day hwt;

run;

rak123
Calcite | Level 5

Thank you all ! That additional statement works!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 4 replies
  • 1046 views
  • 6 likes
  • 4 in conversation