I have a very simple issue, and I read some help material but can't quite solve it.
I want to create some new IDs identifiers combining the session number and the session IDs of my experiment. However, I want these new IDs to have the same number of digits. So the result should be as follows:
session session_ID new_ID
1 1 101
1 2 102
...
1 10 110
1 11 111
...
2 1 201
2 2 202
...
2 10 210
2 11 211
...
If I used Excel, the code would be new_ID = concatenate(session; if(length(session_ID)=1;"0";"");session_ID)
How can this be done in Stata?
Thanks in advance for your help!
gianluca
Related Posts with egen concat including if function
xtgls commandHi everyone, I have a panel data (T=9 and N=24) and I have the three following problems: - heterosce…
Formatting numbers saved in a local and using these in a text outputHello community! I am having troubles understanding the formatting of numbers, or more likely under…
Delete words and rename variablesDear All How can I delete first words from a variable and retain the remaining words. Please find b…
how to produce share (%) of list of countries by sectorI am using stata 14.2 I would like to compute percentages instead of sum so that the total for each …
Dates ConversionI am working with 'dates' in the following format (Day-Month-year): 01-07-03 01-07-03 01-07-0…
Subscribe to:
Post Comments (Atom)
0 Response to egen concat including if function
Post a Comment