- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would like to combine 2 datasets without sorting them, just add a flag to identify where each row coming from.
I have put together the following code but of course it won't work as (in=a) style syntax in not valid for set statement. A simple solution would be great and much appreciated
data output; set table_a (in=a) table_b (in=b); format from $1.; if a then from='A' ; else if b then from='B'; run;
Thanks in advance
Jack
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There's something else wrong with your code - IN is valid in SET.
I would check your log carefully and ensure your data matches what you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have added a line
set ... ; by ID; format ... ;
and it seems working fine. But I am not sure if that works because of the dataset has been sorted or not.
Can someone give me a firm answer? Much appreciated.
Thanks,
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
INDSNAME option.
Data want;
set a b INDSNAME=_source;
source=_source;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you use a BY statement with multiple data sets in the SET statement then you're interleaving data sets not appending.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There's something else wrong with your code - IN is valid in SET.
I would check your log carefully and ensure your data matches what you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hello,
I don't see any reason why your program shouldn't work (except maybe the use of
the reserved word "FROM" for a variable id but that should not be a problem here).
I ran it without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think it works after I added the "by statement"
May be that's all it needs. I will check again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Reeza has the correct idea. What Iwould ask is two questions:
What does "combine two datasets", do you mean set one under the other as combine can mean various things.
Also, what does your data actually contain which a) requires multiple datasets which are the same, and b) has some informatioon in the dataset name which is not in the data? Sounds like a bad setup to start up with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for all the input. I think it was just me wrote some crap code and failed the first time round.