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 and if run again 3_1urn, 3_2urn etc..any ideas..i am having trouble storing the incremented value. At the moment iv got
urn = 1
urn = urn + 1
everytime this is run it read the 1 i need a way to store the new urn value and so it doesnt read the 1...Do i need to create another table?? Also is there a easier way of doing this in DI studio?
You could create a permanent table; read it and update with each execution and store back the new "incremented" value. You would need to consider possibly how to deal with reruns - not sure about your requirement?
Sorry i don't understand what you mean...I have data which i get regular new loads and so i need to update the load number automatically from 1, 2, 3 etc. I then append this in to the URN. I just ned a way of updating 1 to 2 and then 2 to 3 everytime the code is submited
Your idea of tracking a "current load number" across runs could be maintained as a permanent SAS dataset (you must create it in advance and prime it to start), which you process each time your program runs, as follows:
1) Using a DATA step, read the SAS file that has your variable to track the current "load number", and issue a CALL SYMPUT to assign a SAS macro variable with +1 from your "load number" variable.
2) Use the macro variable created in #1 above to update your database variable(s) as required.
3) When processing is finished, store back the new "current load number" into your permanent SAS dataset.
Please share what SAS code you have executing which doesn't provide the SYMPUT correctly, preferably in an executed SAS log (COPY/PASTE into a post-reply).
Also, for your own debugging, consider using the SAS command(s) below to display your user-assigned macro variables -- and there are considerations for GLOBAL versus LOCAL macro variables depending on whether or not you are using the SAS MACRO language: