Hi,
I have a beginner question.
I have two databases in quarterly data. In one of them the variable quarterly is in format $8. (ex: 1991Q1, 1991Q2, 1991Q3 etc) and in the other is in format DDMMYY10 (ex: 01/01/1996 is the first quarter, 01/04/1996 the second, etc).
I need both variables in the same format to make a Merge by the variable in quarterly.
I tried that but it did not work, i get the numbers such 13149, 13240 and i don't undestand why.
DATA IPCH_trim ;
set ipch_trim ;
format trim $8. ;
run ;
Can you help me to change the format please?. Ideally to change the variable in DDMMYY10 format to the format $8.
Thanks you very much
@luciacossaro wrote:
Hi,
I have a beginner question.
I have two databases in quarterly data. In one of them the variable quarterly is in format $8. (ex: 1991Q1, 1991Q2, 1991Q3 etc) and in the other is in format DDMMYY10 (ex: 01/01/1996 is the first quarter, 01/04/1996 the second, etc).
I need both variables in the same format to make a Merge by the variable in quarterly.
I tried that but it did not work, i get the numbers such 13149, 13240 and i don't undestand why.
DATA IPCH_trim ; set ipch_trim ; format trim $8. ; run ;
Can you help me to change the format please?. Ideally to change the variable in DDMMYY10 format to the format $8.
Thanks you very much
I would assume that you would convert it to the quarter but it would help if you showed what the variables look like.
EIther way, use PUT to convert it to a character value, assuming a SAS date to start with:
new_value = put(date, yyq6.);
Play around with the second parameter to get what you want. Also, if you're joining via SQL you can do this on the fly.
@luciacossaro wrote:
Hi,
I have a beginner question.
I have two databases in quarterly data. In one of them the variable quarterly is in format $8. (ex: 1991Q1, 1991Q2, 1991Q3 etc) and in the other is in format DDMMYY10 (ex: 01/01/1996 is the first quarter, 01/04/1996 the second, etc).
I need both variables in the same format to make a Merge by the variable in quarterly.
I tried that but it did not work, i get the numbers such 13149, 13240 and i don't undestand why.
DATA IPCH_trim ; set ipch_trim ; format trim $8. ; run ;
Can you help me to change the format please?. Ideally to change the variable in DDMMYY10 format to the format $8.
Thanks you very much
I would assume that you would convert it to the quarter but it would help if you showed what the variables look like.
EIther way, use PUT to convert it to a character value, assuming a SAS date to start with:
new_value = put(date, yyq6.);
Play around with the second parameter to get what you want. Also, if you're joining via SQL you can do this on the fly.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.