BookmarkSubscribeRSS Feed
shimengj
Fluorite | Level 6

I have a dataset 'wineA', here is the code I have to use, but I cannot read this dataset. I need some help with adding the code of reading 'wineA' into the following code.

 

data wineA2;
input dummy $ @@;
length gender $ 1;
n_char = length(dummy);
gender = substr(dummy,n_char,1);
age = substr(dummy,1,n_char-1);
if last eq 'F' then Female=input(first,5.);
else if last eq 'M' then Male=input(first,5.);
run;

proc print data=wineA2;
run;

8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

Is WineA a SAS data set or an external data set like a txt/csv file ?

shimengj
Fluorite | Level 6
just a dataset I created in my programming
PeterClemmensen
Tourmaline | Level 20

The use a simple Set Statement? 🙂

 

data wineA2;
set wine1;
/* More Code */;
run;
shimengj
Fluorite | Level 6
I tried but the log shows No DATALINES or INFILE statement.
PeterClemmensen
Tourmaline | Level 20

Drop this line and try again.

 

input dummy $ @@;
shimengj
Fluorite | Level 6
does not work... it comes out with a lot of empty variables like age, last. For this step, the question asks me to split variables made up with numbers and characters, ex 32F or 31M. So the final output should have individual variables gender and age.
Sajid01
Meteorite | Level 14

Can you please post your code and sample data as a data step? (Use the running man icon above to open the code windows and place the code there.

In addition do post your log showing the error.(Please click the </> icon above and place the log in that window).

Astounding
PROC Star

While the advice  you have gotten so far contains a lot of good ideas, I think you need more specific guidance on what to do.

 

To begin, while you say you created a data set wineA, notice that your program does not use wineA in any way.  To use it properly, you have to determine what is in wineA.  Is it a SAS data set, or a text file.  If it's a SAS data set, this program will run without error:

data test;
set wineA;
run;

So let's start there and see what you get as the result.  

 

We will probably go through several steps before your question is resolved.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 8 replies
  • 955 views
  • 0 likes
  • 4 in conversation