Good Afternoon,
i need some insight please! 🙂
what im trying to do is, read a column that needs to be seperated.
the column reads 3456789999
what i need to do is pad the first column
so i would split it in two clumns instr(columnA,4,7) to get 6789999
the 2nd column would need to be 0345 as the column needs to be 4 bytes.
and i want to concatenate the result 0345-6789999
Is the current column character or numeric?
Art, CEO, AnalystFinder.com
hi art,
the file im reading isnumeric,
end result as it has a dash, will need to be text which can have leading zero's
Here is one way:
data have; input columna; cards; 3456789999 ; data want; set have; columnb=substr(strip(put(columna,best32.)),4); columnc=substr(put(columna,z11.),1,3); columnd=catx('-',columnc,columnb); run;
Art, CEO, AnalystFinder.com
hi art,
the file im reading is numeric,
end result as it has a dash, will need to be text which can have leading zero's
You can use the Z format to make an 11 character string with leading zeros and then add the hyphen.
Or you could create a picture format. With the picture format you could leave the variable as numeric if you wanted.
proc format ;
picture id low-high='9999-9999999' other=' ';
run;
data text ;
length x1 x2 8 c1 c2 $12;
x1=3456789999 ;
x2=x1;
format x1 z11. x2 id. ;
c1=put(x1,Z11.);
c1=catx('-',substr(c1,1,4),substr(c1,5));
c2=put(x1,id.);
put (_all_) (=/);
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.