DATA Step, Macro, Functions and more

Reading Raw data with double qoutes

Reply
Frequent Learner
Posts: 1

Reading Raw data with double qoutes

Requirement

 

Read the raw data file dat with list input to create the sas Permanent data set Treatment and create the variables from raw data file in following order.

 

Patient_Trial_ID(Numeric) >> Treatment (Character) >> Dosing_Instruction (Character)

 

Now Ensure that your new dataset contains only 3 Variables and 15 Observations.

 

Raw Data

 

1 Palcebo "Dosing with 240ml Distilled water"
2 "Active Drug" "Dosing with 240ml Glucose Water"
3 "Active Drug" "Dosing with 240ml Glucose Water"
4 "Palcebo" "Dosing with 240ml distilled water"
5 "Active Drug" "Dosing with 240ml Glucose Water"
6 "Palcebo" "Dosing with 240ml distilled water"
7 "Active Drug" "Dosing with 240ml Glucose Water"
8 "Palcebo" "Dosing with 240ml distilled water"
9 "Palcebo" "Dosing with 240ml distilled water"
10 "Active Drug" "Dosing with 240ml Glucose Water"
11 "Active Drug" "Dosing with 240ml Glucose Water"
12 "Palcebo" "Dosing with 240ml distilled water"
13 "Active Drug" "Dosing with 240ml Glucose Water"
14 "Palcebo" "Dosing with 240ml distilled water"
15 "Active Drug" "Dosing with 240ml Glucose Water"

 

Can any one sugess me with best answer

Super User
Posts: 17,868

Re: Reading Raw data with double qoutes

What do you have so far? This really looks like homework as well, so you should give it a try. 

 


270992 wrote:

Requirement

 

Read the raw data file dat with list input to create the sas Permanent data set Treatment and create the variables from raw data file in following order.

 

Patient_Trial_ID(Numeric) >> Treatment (Character) >> Dosing_Instruction (Character)

 

Now Ensure that your new dataset contains only 3 Variables and 15 Observations.

 

Raw Data

 

1 Palcebo "Dosing with 240ml Distilled water"
2 "Active Drug" "Dosing with 240ml Glucose Water"
3 "Active Drug" "Dosing with 240ml Glucose Water"
4 "Palcebo" "Dosing with 240ml distilled water"
5 "Active Drug" "Dosing with 240ml Glucose Water"
6 "Palcebo" "Dosing with 240ml distilled water"
7 "Active Drug" "Dosing with 240ml Glucose Water"
8 "Palcebo" "Dosing with 240ml distilled water"
9 "Palcebo" "Dosing with 240ml distilled water"
10 "Active Drug" "Dosing with 240ml Glucose Water"
11 "Active Drug" "Dosing with 240ml Glucose Water"
12 "Palcebo" "Dosing with 240ml distilled water"
13 "Active Drug" "Dosing with 240ml Glucose Water"
14 "Palcebo" "Dosing with 240ml distilled water"
15 "Active Drug" "Dosing with 240ml Glucose Water"

 

Can any one sugess me with best answer


 

Super User
Posts: 10,516

Re: Reading Raw data with double qoutes

Please show the code you used. I suspect that you only need to add a DSD option to an infile statement;

 

data have;
   infile datalines dlm=' ' dsd missover;
   informat row best. cat $20. dose $50.;
   input row cat dose;
datalines;
1 Palcebo "Dosing with 240ml Distilled water"
2 "Active Drug" "Dosing with 240ml Glucose Water"
3 "Active Drug" "Dosing with 240ml Glucose Water"
4 "Palcebo" "Dosing with 240ml distilled water"
5 "Active Drug" "Dosing with 240ml Glucose Water"
6 "Palcebo" "Dosing with 240ml distilled water"
7 "Active Drug" "Dosing with 240ml Glucose Water"
8 "Palcebo" "Dosing with 240ml distilled water"
9 "Palcebo" "Dosing with 240ml distilled water"
10 "Active Drug" "Dosing with 240ml Glucose Water"
11 "Active Drug" "Dosing with 240ml Glucose Water"
12 "Palcebo" "Dosing with 240ml distilled water"
13 "Active Drug" "Dosing with 240ml Glucose Water"
14 "Palcebo" "Dosing with 240ml distilled water"
15 "Active Drug" "Dosing with 240ml Glucose Water"
;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 92 views
  • 0 likes
  • 3 in conversation