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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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