I have a data with numbers like this -
4259311
4262311
18730311
3000001311
3000004311
3000011311
3000013311
3000019311
I get these numbers by joining two rows and have a variable name uni_num
I write a macro to loop over all the numbers and create temp table to manipulate each set.
But while running the code it does well for all numbers which have length less than 8 but does not detect the numbers such as 3000001311.
proc sql;
create table temp_1&i as select * from work.input_for where uni_num = &var.
;
quit;
where my &var is the number above.
I was trying to change the length of number format but with no luck.
Can anyone help me with this?
Thank you.
Does the length option in proc sql solve your problem?Example:
proc sql;
create table myNewData as
select
input(numberStr, best.) as myNumber,
shortStr as longStr length=32
from myData;
quit;
Does the length option in proc sql solve your problem?Example:
proc sql;
create table myNewData as
select
input(numberStr, best.) as myNumber,
shortStr as longStr length=32
from myData;
quit;
@hvempati wrote:I have a data with numbers like this -
4259311
4262311
18730311
3000001311
3000004311
3000011311
3000013311
3000019311
I get these numbers by joining two rows and have a variable name uni_num
I write a macro to loop over all the numbers and create temp table to manipulate each set.
But while running the code it does well for all numbers which have length less than 8 but does not detect the numbers such as 3000001311.proc sql;
create table temp_1&i as select * from work.input_for where uni_num = &var.
;
quit;
where my &var is the number above.
I was trying to change the length of number format but with no luck.
Can anyone help me with this?
Thank you.
Your question is unclear.
Forcing me to guess, I'd say you have a dataset containing:
4259311
4262311
18730311
3000001311
3000004311
3000011311
3000013311
3000019311
And another dataset containing records where uni_num = one of those values.
And you're trying to create separate datasets filtered on those numbers.
Questions:
1) Why? Are you familiar with BY group processing?
2) I suspect creating views rather than tables would give better performance unless your data volume is small.
There are numerous ways to split your data, but first can you say why you need to?
And perhaps make your question clearer?
Oh, and as far as making the length of num longer...is it really num or char? If num, and you're converting to char (say into a macro variable), use a format, such as 32. or best32. to override the default format SAS uses to convert a number to character.
Of course, this is me again guessing exactly what you're doing. Regardless, hope this helps...
Do not split like data, you will just incur additional read/writes, store data in a larger form of disk (due to header block) and create messy unmaintainable code to try to handle it. SAS has built in functionality to deal with this, its called by group processing, and it is quicker and simpler than anything you come up with. As such this question is moot as you will not be doing this.
Next up, post test data in the form of a datastep:
We cannot see your data and this is a key part in any SAS programming task, you say that is a number, is it numeric or text? Where are you getting it from, what do you want to do with it? Provide what manipulation you want to do (i.e. show input test data, and result) and we can provide code to do it.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.