Hello
What is the correct way to create this data set.
Sometimes there are long spaces between items and I dont want to change it manually.
I know that for each variable there should be only one item (or one word only)
Data Longtbl;
input ID field $ labelField $ category $ ;
cards;
1 x1 Team a
1 x2 smoker y
1 x3 status 1
2 x1 Team b
2 x2 smoker n
2 x3 status 2
3 x1 Team c
3 x2 smoker n
3 x3 status 2
4 x1 Team a
4 x2 smoker n
4 x3 status 3
5 x1 Team b
5 x2 smoker y
5 x3 status 1
6 x1 Team a
6 x2 smoker y
6 x3 status 1
7 x1 Team c
7 x2 smoker y
7 x3 status 2
8 x1 Team a
8 x2 smoker n
8 x3 status 2
9 x1 Team a
9 x2 smoker y
9 x3 status 3
;
run;
The delimiter in your data is sometimes space '20'x and sometimes tab '09'x or both.
To read the the data ceorrectly I have added an INFILE statement with appropriate options:
Data Longtbl;
infile cards dlm='2009'x truncover;
input ID field $ labelField $ category $ ;
cards;
1 x1 Team a
1 x2 smoker y
1 x3 status 1
2 x1 Team b
2 x2 smoker n
2 x3 status 2
3 x1 Team c
3 x2 smoker n
3 x3 status 2
4 x1 Team a
4 x2 smoker n
4 x3 status 3
5 x1 Team b
5 x2 smoker y
5 x3 status 1
6 x1 Team a
6 x2 smoker y
6 x3 status 1
7 x1 Team c
7 x2 smoker y
7 x3 status 2
8 x1 Team a
8 x2 smoker n
8 x3 status 2
9 x1 Team a
9 x2 smoker y
9 x3 status 3
;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.