BookmarkSubscribeRSS Feed
mahfuz_pops
Calcite | Level 5

hi,

Problem-I:

 

suppose I have following variables: v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24, v25,v26 and so on

Is it possible to rename those variables which will take following respective names: 

6.98,7.98,8.98,9.98,10.98,11.98,12.98,1.99,2.99,3.99,4.99,5.99,6.99,7.99,8.99,9.99,10.99,11.99,12.99,1.00,2.00,3.00,4.00,5.00,6.00,7.00,8.00,9.00,10.00,11.00,12.00......and so on.

the number before the dot is month, and the number after the dot is year. I want to do this for a large number of variables, so I don't want code with fixed number of years, rather it would be with variable year. Can you write a code for this?

 

Problem-I:

Suppose I have data, now I want to delete the cases whose ages are greater than 25 born in Australia, if the variable for age is A and Country of birth is C, can u also write a code for this? 

2 REPLIES 2
Reeza
Super User
SAS variables typically can't follow that format and I wouldn't recommend it. Look into using labels instead.
LinusH
Tourmaline | Level 20

Fist, you cannot expect anyone else to write the code for you, especially when you haven't even tried yourself.

 

So,  you can't rename variables in that manner, they don't comply with SAS naming standards (or any other database that I know of).

My suggestion is that you transpose your data set to make the variables classifier values instead - then you can rename them almost any way you want. Take a look at PROC TRANSPOSE, or the data step with explicit output.

 

Your second problem looks like a normal WHERE statement with a combination of conditions, should be no problem for your to write it.

Data never sleeps

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 723 views
  • 0 likes
  • 3 in conversation