BookmarkSubscribeRSS Feed
carl_miles
Calcite | Level 5

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?

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
Calcite | Level 5
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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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