Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS HELP!

Status
Not open for further replies.

sasbeginner

Technical User
Oct 4, 2009
1
GB
Hi i am using sas and need help on construction a new URN. I currently have a URN field which is populated with 1_1urn, 1_2urn, 1_3urn etc..now everytime the code is run i need the urn to increment by 1..so the next time it is run the urn is 2_1urn, 2_2urn, 2_3urn etc..any ideas..i was thinking of using an sql update statment....
 
You can split the numbers out and increment it, then put it back in. I'm assuming that the record is the same record, you're just incrementing the URN on the record yes?
Code:
data outdat;
  set indat;

  num = input(scan(URN,1,'_'),2.);
  second_part = scan(URN,2,'_');
  num2 = num + 1;
  new_urn = catx('_',put(num2,2.),second_part);
run;

Try that and see if it gives you what you want.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top