Hi All,
I have data issue while making reshape of the below data, kindly someone help me out for this scenario
{
data _nu;
infile datalines;
input num1
datalines;
1 2 3 4 5 ;
run;
my expecting results should be
num1
1
2
3
4
5
I want to reshape horizontal to vertical
Thanks & regards
Rohit
data wide;
input num1-num5;
datalines;
1 2 3 4 5
;
proc transpose data=wide out=long(rename=COL1=num drop=_NAME_);
run;
Please supply a WORKING step with datalines.
Is num1 thought to be a string with all the digits, or do you rather have 5 numerical values in one observation?
Or do you want to read a text file that has all the numbers on one line?
That would be very easy with a "double hold":
data _nu;
infile datalines;
input num1 @@;
datalines;
1 2 3 4 5
;
run;
Adding some fun
data _nu;
infile datalines;
array num(5);
input num(*);
do _n_= 1 to 5;
numbers=num(_n_);
output;
end;
keep numbers;
datalines;
1 2 3 4 5
;
run;
Hi @rohitkrishna Can you post a sample of the data you have and your expected output that you want plz? Makes it easier to code it for you
Okay and what is the output you want from that?
But your previous post showed two strings in the first observation:
@rohitkrishna wrote:
Ya novinosrin,
i want the rec into vertical
like
R M********N
T**B
like above one after another
Thanks & regards
rohit
So you have three strings in one input line, and you want the third string to go into a new observation?
@rohitkrishna wrote:
Hi novinosrin
Thanks for the response
please find below mention data
{
R M********N T**B
D N******E T**B
L H**********N T**B
R S***********N T**B
K *******L T**B
Thanks & regards
rohit
@rohitkrishna wrote:
Hi
try to provide some solution for the above issue
Thanks & regards
Rohit
Since your rule does not match your expected output, I can't do that.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.