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

Hi,

 

I have two datasets:

 

Dataset A:

ID  Gender

1     M

 

Dataset B:

Date

1/1/2010

1/2/2010

 

I'm trying to create a dataset that looks like this:

ID  Gender  Date

1     M          1/1/2010

1     M          1/2/2010

 

Is that possible?

1 ACCEPTED SOLUTION

Accepted Solutions
KatLinden
Obsidian | Level 7

Thank you so much!  

View solution in original post

9 REPLIES 9
novinosrin
Tourmaline | Level 20

 

data a;
input ID  Gender $;
cards;
1     M
;
data b;
input Date $10.;
cards;
1/1/2010
1/2/2010
;
data want;
if 0 then set a;
set b;
if _n_=1 then set a;
run;

 

KatLinden
Obsidian | Level 7

Thank you so much!  

novinosrin
Tourmaline | Level 20

@KatLinden Welcome to the SAS community forum. I hope you have a fun journey with us 🙂

KatLinden
Obsidian | Level 7

Thank you!  One more question.  How does this work if I have several observations in dataset A?

 

I have two datasets:

 

Dataset A:

ID  Gender

1     M

2     F

.

.

.

etc

 

Dataset B:

Date

1/1/2010

1/2/2010

 

I'm trying to create a dataset that looks like this:

ID  Gender  Date

1     M          1/1/2010

1     M          1/2/2010

2     F           1/1/2010

2     F           1/2/2010

.

.

.

etc

 

novinosrin
Tourmaline | Level 20

I would request you to provide us a more comprehensive and complete representative sample. Your data doesn't seem to have clear logic of match apart from mere plugging in 1 and 2 dates to gender category. Or is that all the data is?

KatLinden
Obsidian | Level 7

Yes, but I have hundreds of observations in dataset A, each observation has a unique ID and I need to insert 2 dates.

novinosrin
Tourmaline | Level 20
data a;
input ID  Gender $;
cards;
1     M
2     F
;
data b;
input Date $10.;
cards;
1/1/2010
1/2/2010
;
proc sql;
create table want as
select *
from a,b
order by id,gender;
quit;
novinosrin
Tourmaline | Level 20

still i am only playing with your data without making much sense lol 

KatLinden
Obsidian | Level 7

That worked perfectly!  Thank you so much!

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