BookmarkSubscribeRSS Feed
mansour_ibrahim
Obsidian | Level 7

 

 

Hello,

I want to complete each series present in the table test1 by a value tmp

when absent relative to the var1 of the test table

 

 

 

data test;
input var1;
cards;
1
2
3
;run;

data test1;
input var1;
cards;
1
2
3
2
3
1
2
;run;

desired results

1
2
3
tmp
2
3
1
2
tmp

 

 

 

Thank you

 

2 REPLIES 2
mkeintz
PROC Star

This would be a nice homework assignment.   What have you tried so far?  If you've tried nothing, then let us now how you would logically perform the task.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ballardw
Super User

In your example the variable Var1 is numeric. As such it can never hold the value "tmp" which is character.

 

Also, what would the result be if your data looked like:

data test1;
input var1;
cards;
4
5
7
1
2
3
2
3
1
2
;run;

or

 

data test1;
input var1;
cards;
4
5
7
1
2
3
2
3
1
2
5
1
2
3
3
3
;run;

You will have to expand a bit on your definition of what a "series" is and "absent relative".

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1051 views
  • 0 likes
  • 3 in conversation