BookmarkSubscribeRSS Feed
carl_miles
Obsidian | Level 7

cust_id   date1                date2                 date3

1001        15JAN2023    20FEB2023     30MAR2023

I want an ouput like 

cust_id   date1                date2                 date3                  date 4

1001        15JAN2023    20FEB2023     30MAR2023    15JAN2023

1001        15JAN2023    20FEB2023     30MAR2023    20FEB2023 

 

if you guys see date1 and date2 are appended against date3 

like that i want an output 
i have dataset of 15000 rows
kindly guide me here 

 

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

Do you want a third row with the value of date3 also?

carl_miles
Obsidian | Level 7
No
PaigeMiller
Diamond | Level 26

@carl_miles wrote:

cust_id   date1                date2                 date3

1001        15JAN2023    20FEB2023     30MAR2023

I want an ouput like 

cust_id   date1                date2                 date3                  date 4

1001        15JAN2023    20FEB2023     30MAR2023    15JAN2023

1001        15JAN2023    20FEB2023     30MAR2023    20FEB2023 

 

if you guys see date1 and date2 are appended against date3 

like that i want an output 
i have dataset of 15000 rows
kindly guide me here 

 


I feel like I don't understand where date4 comes from, or why it is needed. I don't understand how many rows will be created from this initial one row data set. What happens if there are more CUST_ID values, then what?

--
Paige Miller
carl_miles
Obsidian | Level 7
ITS FINE
PaigeMiller
Diamond | Level 26

@carl_miles wrote:
ITS FINE

This extreme level of brevity does not help me understand the problem.

--
Paige Miller
mkeintz
PROC Star

You can see the lack of specific suggestions in the responses to your posting.

 

I think this is primarily due to the absence of a clear description (or of any description at all) of your objective.

 

I suspect for every incoming observation, you want to generate two observations, one with DATE4=DATE1, and the second with DATE4=DATE2.  But that notion is nothing more than an attempt at mindreading, a skill I do not trust.

 

If you can clearly state what you want to dio you would get a lot more help.  Please help us help you.

--------------------------
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

This accomplishes what you ask for the shown values.

First is a data step to actually have values.

data have;
 input cust_id date1 :date9. date2 :date9.  date3 :Date9.;
 format date: date9.;
datalines;
1001 15JAN2023 20FEB2023 30MAR2023
;

data want;
   set have;
   array d (*) date1 date2;
   do i= 1 to dim(d);
      date4=d[i];
      output;
   end;
   format date4 date9.;
   drop i;
run;

Why? I don't see any practical use.

 

What do you intend to do with the resulting set? It may be this step just adds complications on the way to your goal.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 7 replies
  • 1702 views
  • 0 likes
  • 5 in conversation