BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
luciacossaro
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@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. 

View solution in original post

1 REPLY 1
Reeza
Super User

@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. 

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 904 views
  • 0 likes
  • 2 in conversation