BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
knveraraju91
Barite | Level 11

Please suggest to get the output. Thank you

I need to replace mean,medain,cv with '-' if row with 'n' has less than 3.

for param='a',  s2 column has 2 for n, so I need to change the mean,median,cv to '-'.

for param='b',  s2 and s3 columns have 2 and1, so I need to change the mean,median,cv to '-'.

output needed:

3 2 4 n a
5 - 8 mean a
4 - 5 meadin a
10 - 15 cv a
3 2 1 n b
5 - - mean b
4 - - meadin b
10 - - cv b

data aa;
input s1 $ s2 $ s3 $ r3 $ param $;
datalines;
3 2 4 n a
5 6 8 mean a
4 7 5 meadin a
10 20 15 cv a
3 2 1 n b
5 6 8 mean b
4 7 5 meadin b
10 20 15 cv b
;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Please go back and edit your subject line so that it is descriptive of your problem. There's no point in a subject "Help in my pgm" as almost every question here could have that subject line. The Community is trying to help you, but you have to help the Community.

 

 

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Please go back and edit your subject line so that it is descriptive of your problem. There's no point in a subject "Help in my pgm" as almost every question here could have that subject line. The Community is trying to help you, but you have to help the Community.

 

 

--
Paige Miller
knveraraju91
Barite | Level 11
HI

I am trying to update subject line. I do not see any options to update the subject line.

Thank you
PaigeMiller
Diamond | Level 26

It may be that the time allowed to edit your original post has expired.

--
Paige Miller
Tom
Super User Tom
Super User

Why do you have the data is such a strange layout?

Is PARAM the key variable that let's you link the observations with N to the observations with the MEDIAN?

 

Why isn't the data organized like this:

data have;
  input param $ repeat n mean median cv;
cards;
a 1 3 5 4 10
a 2 2 6 7 20
a 3 4 8 5 15
b 1 3 5 4 10
b 2 2 6 7 20
b 3 1 8 5 15
;

Then the request change is easy;

data want ;
  set have;
  if N< 3 then call missing(of mean median cv);
run;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 485 views
  • 1 like
  • 3 in conversation