BookmarkSubscribeRSS Feed
cm3
Fluorite | Level 6 cm3
Fluorite | Level 6
Hi, Can someone pls help with the below logic
There are total 25 variables in my dataset and two of them are userformid , Score. I want to populate all 25 values for only first.userformid. For rest all observations populate only Score values.
Thanks
6 REPLIES 6
PaigeMiller
Diamond | Level 26

Sorry, you'll have to show us a (portion of) your data. I don't understand what you want.

 

Also show us the desired output.

 

Don't show us one and not the other.

--
Paige Miller
cm3
Fluorite | Level 6 cm3
Fluorite | Level 6
For ex my data set is like below
Userformid RS min_rs max_rs grade score
E031000. 4. 2. 5. E03. 303
E031000. 2. 2. 5. E03. 303
E031000. 5. 2. 5. E03. 312
E03100S. 1. 1. 4. E03. 309
E03100S. 3. 1. 4. E03. 300
E03100S. 4. 1. 4. E03. 304

I need my output data set as below

Userformid RS min_rs max_rs grade score
E031000. 4 2 5 E03. 303
303
312
E03100S. 1 1 4 E03. 309
300
304

Thank you !
cm3
Fluorite | Level 6 cm3
Fluorite | Level 6
Correction typo mistake below
E031000. 4 2 5 E03. 303
303
312
E03100S. 1 1 4 E03. 309
300
304
ballardw
Super User

@cm3 wrote:
Correction typo mistake below
E031000. 4 2 5 E03. 303
303
312
E03100S. 1 1 4 E03. 309
300
304

Get your text, in a plain text editor like the SAS editor or Notepad. The paste into a code box using the forum's {I} to preserve the format. Otherwise the forum strips a lot of blanks, tabs and such. I am guessing that you intended something like:

E031000. 4 2 5 E03. 303
                    303
                    312
E03100S. 1 1 4 E03. 309
                    300
                    304

which would indeed be a bad structure for an actual data set. If you are wanting a REPORT that is read by people and not data fed into other procedures then say so.

 

 

The reason this would be bad as a data set is that the value of the variable userformid is no longer available for grouping for any purpose on most records. So summarizations and such are likely to be off.

cm3
Fluorite | Level 6 cm3
Fluorite | Level 6
303 312 300 304 are Score values and should be under last column
Userformid RS min_rs max_rs grade as null values
Patrick
Opal | Level 21

@cm3

It feels wrong to create such a data structure but here you go.

data want;
  set have;
  by Userformid;
  if not first.Userformid then
    do;
      call missing(Userformid, RS, min_rs, max_rs, grade);
    end;
run;

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!

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