Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Assigning serial number and date to new observation

Reply
New Contributor
Posts: 2

Assigning serial number and date to new observation

[ Edited ]

I maintain a dataset named as "XYZ" . eg. XYZ contains only one column as show name A, B, C, X, Y, Z....

Dataset XYZ:

Show_name
A
B
C
X
Y
Z

 

 

Every week I update the dataset XYZ and sort them to get dataset ABC with the below code.     

 

/*Sort all show name in ascending order*/

Proc Sort Data=XYZ;

By Show_Name;

Run;

 

/*Create Serial number and Date stamp*/

Data ABC;

Set XYZ;Format Date mmddyy.;

Serial_no=_n_;

Date=today();

Run;

 

Dataset ABC:

Serial NoDateShow_Name
13/23/2016 A
23/23/2016B
33/23/2016C
43/23/2016X
53/23/2016Y
63/23/2016

Z

 

 Now, in future when I refresh XYZ and see a new show in the list (eg. P and Q).so instead of sorting and giving serial number. I just want to sort new show_name and give serial number to P and Q. only. 

 

Desired Output:

Serial NoDateShow_name
13/23/2016A
23/23/2016B
33/23/2016C
43/23/2016X
53/23/2016Y
63/23/2016Z
73/24/2016P
83/24/2016Q

  

Super User
Posts: 11,343

Re: Assigning serial number and date to new observation

Posted in reply to ameshram28

Please describe how you would add the values of P and Q on the later date.

Different approaches  would be open depending on your method.

New Contributor
Posts: 2

Re: Assigning serial number and date to new observation

I maintain a dataset named XYZ, which I refresh on monthly basis. 

Respected Advisor
Posts: 4,927

Re: Assigning serial number and date to new observation

Posted in reply to ameshram28

Varaible?

 

Data ABC;
Set XYZ end=done;
output;
if done then do;
	date = today();
	serial_no = serial_no + 1;
	varaible = "P";
	output;
	serial_no = serial_no + 1;
	varaible = "Q";
	output;
	end;
Run;
PG
Ask a Question
Discussion stats
  • 3 replies
  • 295 views
  • 0 likes
  • 3 in conversation