Hi All,
I have some stored IDs that I need to assign to my observations. At the end I also want to disappear those IDs from that ID table and update that table.
DATA Have;
INPUT Course_ID$ age State$;
DATALINES;
ENG1 15 NY
Che1 10 NY
Eng2 15 CA
Phy2 11 PA
Che1 15 TX
;
RUN;
DATA ids;
INPUT slno;
DATALINES;
107
101
105
116
264
552
145
235
224
117
100
;
RUN;
PROC SORT DATA=ids;
BY slno;
RUN;
At the end I want the table 'Have' to be populated with slno from 'ids' table and lname it as want:
Want
slno course_ID Age State
100 ENG1 15 NY
101 Che1 10 NY
105 Eng2 15 CA
107 Phy2 11 PA
116 Che1 15 TX
Also, at the end ids table should stay with the remaining slno:
ids
slno
117
145
224
235
264
552
Thanks for your help in advance
Here's some code that I think will get what you're looking for!
DATA have ids(KEEP=slno);
MERGE ids (IN=a)
have (IN=b);
IF a AND b THEN output have;
IF a AND not b THEN output ids;
RUN;
I've told the IDs to mash up horizontally with the data in have and only print to the have data set if there was a match. For cases where there was an ID but nothing to match it to, it was added back to ids and only the slno variable was preserved;
Here's some code that I think will get what you're looking for!
DATA have ids(KEEP=slno);
MERGE ids (IN=a)
have (IN=b);
IF a AND b THEN output have;
IF a AND not b THEN output ids;
RUN;
I've told the IDs to mash up horizontally with the data in have and only print to the have data set if there was a match. For cases where there was an ID but nothing to match it to, it was added back to ids and only the slno variable was preserved;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.