DATA Step, Macro, Functions and more

Need to add a last column after using proc transpose

Reply
Contributor
Posts: 60

Need to add a last column after using proc transpose

Hi I have a tranpose dataset (converting form numners in to variables)  with a prefix statement and Now I need to add a new column to the dataset Date_produced after the form_1-till the form_end . NoI will not be able to add the last couln sincI am not sure how may form numbers would come in the data set . Please help me how to tackel this issue .Below the code

proc transpose data = wc_forms_nat out = nat_forms (drop = _name_) prefix = FORM_;
	var form_nbr ;
	by claim_id Form_Issued_Date ;
run;
Super User
Posts: 10,552

Re: Need to add a last column after using proc transpose

Please show what your resulting data set should look like. It is not clear in what way "how may form numbers would come in the data set " would affect adding a single column called "date_Produced". What values should be assigned to that variable when added?

Contributor
Posts: 60

Re: Need to add a last column after using proc transpose

Hi ,

 

The new date set columns shoule be in the following order

 

Clm sx date form_1 form_2 to form_n Date_Produced

 

I tried using retain statement for ordering , later I realised that the form numbers may different (could be more sometimes ) , So how I can add Date_Produced column at the end of this data set ( Date_Produce column has the date of the report created (sysdate) 

Super User
Super User
Posts: 7,433

Re: Need to add a last column after using proc transpose

Without any information on where that variable is coming or anything I would guess at:

data nat_forms;
set nat_forms;
date_produced="01JAN2017"d;
run;
Super User
Posts: 10,552

Re: Need to add a last column after using proc transpose


ambadi007 wrote:

Hi ,

 

The new date set columns shoule be in the following order

 

Clm sx date form_1 form_2 to form_n Date_Produced

 

I tried using retain statement for ordering , later I realised that the form numbers may different (could be more sometimes ) , So how I can add Date_Produced column at the end of this data set ( Date_Produce column has the date of the report created (sysdate) 


Concern about the order of columns in a data set should generally be a low priority. A vast majority of what you may do in SAS will no be affected by the order of the data. If you need columns in a specific order for use by another program after exporting data from SAS then use appropriate tools when writing the output to match. SAS is concerned about the variable name for almost everything.

Ask a Question
Discussion stats
  • 4 replies
  • 103 views
  • 0 likes
  • 3 in conversation