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
JDBC connection to Google BigQuery DatabaseDoes anyone here connect to BQ using JDBC successfully? I've been trying to make this work, as I did…
Counts Across Unique IdentifierHi Everyone, I am working with a dataset that has foloowing varibales: 1) mrn (unique identifier) …
Esttab in a loop and getting table for summary statisticsHello everyone, I have a question about esttab command in a loop and getting the entire output in an…
vmatch functionDear community members, I need to match my cases with exact controls on several variables. I heard …
Estimation of GMM model with time dummiesDear Scholars/Researchers, I am still confused and would like to ask that, Is it necessary to estima…
Subscribe to:
Post Comments (Atom)
0 Response to egen concat including if function
Post a Comment