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

Hi,

I have a dataset with 7 individuals (ID) and 2 households (FAM). In addition, I have two variables, Ink and Disp. Ink shows the individual's income while Disp shows the households' disposable income. Disp thus repeats itself. I want the variable disp to be kept for the first individual in the household and get a value missing for the rest of the individuals in the household. Below is the code that shows what I have and how I want it to be. thank you!

DATA HAVE;
INPUT ID FAM INK DISP;

DATALINES;

1 1 50 60

2 1 100 60

3 1 200 60

4 2 500 250

5 2 700 250

6 2 0 250

7 2 0 250

;

RUN;

DATA WANT;

INPUT ID FAM INK DISP;

DATALINES;

1 1 50 60

2 1 100 .

3 1 200 .

4 2 500 250

5 2 700 .

6 2 0 .

7 2 0 .

;

RUN;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   by fam;
   if not first.fam then disp = .;
run;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   by fam;
   if not first.fam then disp = .;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 644 views
  • 1 like
  • 2 in conversation